当前位置: 首页>>代码示例>>Java>>正文


Java JsonLoader.fromResource方法代码示例

本文整理汇总了Java中com.github.fge.jackson.JsonLoader.fromResource方法的典型用法代码示例。如果您正苦于以下问题:Java JsonLoader.fromResource方法的具体用法?Java JsonLoader.fromResource怎么用?Java JsonLoader.fromResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.fge.jackson.JsonLoader的用法示例。


在下文中一共展示了JsonLoader.fromResource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _validate

import com.github.fge.jackson.JsonLoader; //导入方法依赖的package包/类
protected ProcessingReport _validate(JsonNode json) throws IOException {
    final JsonNode belSchema = JsonLoader.fromResource("/bel-json-graph.schema.json");
    final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
    final JsonSchema schema;
    try {
        schema = factory.getJsonSchema(belSchema);
        return schema.validate(json, true);
    } catch (ProcessingException e) {
        throw new IOException(e);
    }
}
 
开发者ID:jsongraph,项目名称:jgf-app,代码行数:12,代码来源:GraphReaderImpl.java

示例2: GenericOpenRtbValidator

import com.github.fge.jackson.JsonLoader; //导入方法依赖的package包/类
/**
    * Constructs a JSON validator using the given schema read as a resource.
    * 
    * @param schemaResource
    *            the schema resource
    */
   GenericOpenRtbValidator(String schemaResource) {
	try {
		JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
		JsonNode jsonNode = JsonLoader.fromResource(schemaResource);
		schema = factory.getJsonSchema(jsonNode);
	} catch (IOException | ProcessingException e) {
		throw new IllegalStateException("could not initialize validator due to previous exception", e);
	}
}
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:16,代码来源:GenericOpenRtbValidator.java

示例3: main

import com.github.fge.jackson.JsonLoader; //导入方法依赖的package包/类
public static void main(final String... args)
        throws IOException, ProcessingException
{
    final JsonNode googleAPI
            = JsonLoader.fromResource("/perftest.json");
    final Map<String, JsonNode> googleSchemas
            = JacksonUtils.asMap(googleAPI.get("schemas"));

    long begin, current;
    begin = System.currentTimeMillis();
    doValidate(googleSchemas, -1);
    current = System.currentTimeMillis();

    System.out.println("Initial validation :" + (current - begin) + " ms");

    begin = System.currentTimeMillis();
    for (int i = 0; i < 500; i++) {
        doValidate(googleSchemas, i);
        if (i % 20 == 0) {
            current = System.currentTimeMillis();
            System.out.println(String.format("Iteration %d (in %d ms)", i,
                    current - begin));
        }
    }

    final long end = System.currentTimeMillis();
    System.out.println("END -- time in ms: " + (end - begin));
    System.exit(0);
}
 
开发者ID:networknt,项目名称:json-schema-validator-perftest,代码行数:30,代码来源:FgePerf.java

示例4: validate

import com.github.fge.jackson.JsonLoader; //导入方法依赖的package包/类
private void validate(String schemaPath, String filePath) throws IOException, ProcessingException {
    JsonNode schema = JsonLoader.fromResource(schemaPath);
    JsonNode json = JsonLoader.fromPath(filePath);
    com.github.fge.jsonschema.main.JsonValidator validator = JsonSchemaFactory.byDefault().getValidator();
    ProcessingReport report = validator.validate(schema, json);

    if ((report == null) || !report.isSuccess()) {
        logger.error("Invalid JSON");
        if (report != null) {
            throw new ProcessingException(report.toString());
        } else {
            throw new ProcessingException("JSON validation report is null for " + filePath);
        }
    }
}
 
开发者ID:flipkart-incubator,项目名称:Poseidon,代码行数:16,代码来源:JsonValidator.java

示例5: testGetJsonValidation

import com.github.fge.jackson.JsonLoader; //导入方法依赖的package包/类
@Test
public void testGetJsonValidation() throws Exception {
    MathTag tag = new MathTag(1, "a+b", WikiTextUtils.MathMarkUpType.LATEX);
    final String real = "[" + tag.toJson() + "]";
    final JsonNode jsonSchema = JsonLoader.fromResource("/formula_list_schema.json");
    final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
    final JsonSchema schema = factory.getJsonSchema(jsonSchema);
    ProcessingReport report = schema.validate(JsonLoader.fromString(real));
    assertTrue(report.isSuccess());
}
 
开发者ID:ag-gipp,项目名称:mathosphere,代码行数:11,代码来源:MathTagTest.java

示例6: getJsonNodeFromResource

import com.github.fge.jackson.JsonLoader; //导入方法依赖的package包/类
public static JsonNode getJsonNodeFromResource(String resource) 
throws IOException
{
    return JsonLoader.fromResource(resource);
}
 
开发者ID:deib-polimi,项目名称:diceH2020-space4clouds_shared,代码行数:6,代码来源:ValidationUtils.java


注:本文中的com.github.fge.jackson.JsonLoader.fromResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。