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


Java JsonLoader类代码示例

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


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

示例1: validate

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@SneakyThrows
private boolean validate(Map<String, Object> data, String jsonSchema) {

    String stringData = objectMapper.writeValueAsString(data);
    log.debug("Validation data. map: {}, jsonData: {}", data, stringData);

    JsonNode schemaNode = JsonLoader.fromString(jsonSchema);

    JsonNode dataNode = JsonLoader.fromString(stringData);
    JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
    JsonSchema schema = factory.getJsonSchema(schemaNode);
    val report = schema.validate(dataNode);

    boolean isSuccess = report.isSuccess();
    if (!isSuccess) {
        log.info("Validation data report: {}", report.toString().replaceAll("\n", " | "));
    }
    return isSuccess;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:20,代码来源:JsonDataValidator.java

示例2: testBidRequestExample2ExpandableCreative

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidRequestExample2ExpandableCreative() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, OpenRtbVersion.V2_0);

  	// NOTE: IABs example is invalid due to:
  	// 1. "device.flashversion" should be "device.flashver"
  	// 2. "site.sitecat" should be "site.cat"
  	// 3. "imp.banner.expandable" should be "imp.banner.expdir"
  	// 4. "imp.banner.iframebuster" should be "imp.iframebuster"
  	// 5. "site.content.keyword" should be "site.content.keywords"
  	// 6. "site.content.keywords" should be a comma delimited string, not array of strings
String invalidResource = "/v2_0/bid_requests/example2_expandable_creative.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());

String resource = "/v2_0/bid_requests/fixed/example2_expandable_creative.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

      logger.info("validation result: " + result);
      assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:24,代码来源:OpenRtbValidatorV2_0Tests.java

示例3: testBidRequestExample3Mobile

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidRequestExample3Mobile() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, OpenRtbVersion.V2_0);

// NOTE: IABs example is invalid due to:
  	// 1. "app.appcat" should be "app.cat"
  	// 2. "app.content.keyword" should be "app.content.keywords"
  	// 3. "app.content.keywords" should be a comma delimited string, not array of strings
  	String invalidResource = "/v2_0/bid_requests/example3_mobile.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());

  	String resource = "/v2_0/bid_requests/fixed/example3_mobile.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

      logger.info("validation result: " + result);
      assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:21,代码来源:OpenRtbValidatorV2_0Tests.java

示例4: testBidResponseExample3VastXmlDocumentReturnedInline

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidResponseExample3VastXmlDocumentReturnedInline() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_RESPONSE, OpenRtbVersion.V2_0);

// NOTE: IABs example is invalid due to:
  	// 1. "seatbid[0].bid.impid is required but missing
  	String invalidResource = "/v2_0/bid_responses/example3_vast_xml_document_returned_inline.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());
  	
  	String resource = "/v2_0/bid_responses/fixed/example3_vast_xml_document_returned_inline.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

      logger.info("validation result: " + result);
      assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:19,代码来源:OpenRtbValidatorV2_0Tests.java

示例5: testBidRequestExample1SimpleBanner

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidRequestExample1SimpleBanner() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, OpenRtbVersion.V2_2);

// NOTE: IABs example is invalid due to:
  	// 1. "device.ip" is not valid a valid ip address
  	// 2. "site.cat" is not an array
  	// 3. "site.publisher.cat" is not an array
  	String invalidResource = "/v2_2/bid_requests/example1_simple_banner.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());

  	String resource = "/v2_2/bid_requests/fixed/example1_simple_banner.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

logger.info("validation result: " + result);
assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:21,代码来源:OpenRtbValidatorV2_2Tests.java

示例6: testBidRequestExample2ExpandableCreative

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidRequestExample2ExpandableCreative() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, OpenRtbVersion.V2_2);

// NOTE: IABs example is invalid due to:
  	// 1. "device.ip" is not valid a valid ip address
  	// 2. "site.cat" is not an array
  	// 3. "site.publisher.cat" is not an array
  	// 4. "imp.banner.expandable" should be "imp.banner.expdir"
  	// 5. "imp.banner.iframebuster" should be "imp.iframebuster"
  	String invalidResource = "/v2_2/bid_requests/example2_expandable_creative.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());
  	
String resource = "/v2_2/bid_requests/fixed/example2_expandable_creative.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

      logger.info("validation result: " + result);
      assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:23,代码来源:OpenRtbValidatorV2_2Tests.java

示例7: testBidRequestExample3Mobile

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidRequestExample3Mobile() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, OpenRtbVersion.V2_2);

// NOTE: IABs example is invalid due to:
  	// 1. "app.cat" contains an invalid category
  	// 2. "user.yob" should be an integer
  	String invalidResource = "/v2_2/bid_requests/example3_mobile.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());
  	
  	String resource = "/v2_2/bid_requests/fixed/example3_mobile.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

      logger.info("validation result: " + result);
      assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:20,代码来源:OpenRtbValidatorV2_2Tests.java

示例8: testBidRequestExample5PmpWithDirectDeal

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidRequestExample5PmpWithDirectDeal() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, OpenRtbVersion.V2_2);

// NOTE: IABs example is invalid due to:
  	// 1. "device.ip" is not valid a valid ip address
  	// 2. "site.cat" is not an array
  	// 3. "site.publisher.cat" is not an array
  	String invalidResource = "/v2_2/bid_requests/example5_pmp_with_direct_deal.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());

String resource = "/v2_2/bid_requests/fixed/example5_pmp_with_direct_deal.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

      logger.info("validation result: " + result);
      assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:21,代码来源:OpenRtbValidatorV2_2Tests.java

示例9: testBidResponseExample3VastXmlDocumentReturnedInline

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidResponseExample3VastXmlDocumentReturnedInline() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_RESPONSE, OpenRtbVersion.V2_2);

// NOTE: IABs example is invalid due to:
  	// 1. "bid.id" is not a string
  	// 2. "bid.impid" is not a string
  	String invalidResource = "/v2_2/bid_responses/example3_vast_xml_document_returned_inline.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());

String resource = "/v2_2/bid_responses/fixed/example3_vast_xml_document_returned_inline.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

      logger.info("validation result: " + result);
      assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:20,代码来源:OpenRtbValidatorV2_2Tests.java

示例10: testBidRequestExample1SimpleBanner

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidRequestExample1SimpleBanner() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, OpenRtbVersion.V2_1);

// NOTE: IABs example is invalid due to:
  	// 1. "site.content.keywords" should be a comma delimited string, not array of strings
  	String invalidResource = "/v2_1/bid_requests/example1_simple_banner.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());
  	
  	String resource = "/v2_1/bid_requests/fixed/example1_simple_banner.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

      logger.info("validation result: " + result);
      assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:19,代码来源:OpenRtbValidatorV2_1Tests.java

示例11: testBidRequestExample2ExpandableCreative

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidRequestExample2ExpandableCreative() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, OpenRtbVersion.V2_1);

// NOTE: IABs example is invalid due to:
  	// 1. "device.flashversion" should be "device.flashver"
  	// 2. "site.sitecat" should be "site.cat"
  	// 3. "imp.banner.expandable" should be "imp.banner.expdir"
  	// 4. "imp.banner.iframebuster" should be "imp.iframebuster"
  	// 5. "site.content.keyword" should be "site.content.keywords"
  	// 6. "site.content.keywords" should be a comma delimited string, not array of strings
  	String invalidResource = "/v2_1/bid_requests/example2_expandable_creative.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());

String resource = "/v2_1/bid_requests/fixed/example2_expandable_creative.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

      logger.info("validation result: " + result);
      assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:24,代码来源:OpenRtbValidatorV2_1Tests.java

示例12: testBidRequestExample3Mobile

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
public void testBidRequestExample3Mobile() throws IOException {
	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_REQUEST, OpenRtbVersion.V2_1);
		
	// NOTE: IABs example is invalid due to:
	// 1. "app.appcat" should be "app.cat"
	// 2. "app.content.keyword" should be "app.content.keywords"
	// 3. "app.content.keywords" should be a comma delimited string, not array of strings
	String invalidResource = "/v2_1/bid_requests/example3_mobile.json";
    ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

    logger.info("invalid validation result: " + invalidResult);
    assertFalse(invalidResource + " is valid", invalidResult.isValid());
	
	String resource = "/v2_1/bid_requests/fixed/example3_mobile.json";
    ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

    logger.info("validation result: " + result);
    assertTrue(resource + " is not valid", result.isValid());
}
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:21,代码来源:OpenRtbValidatorV2_1Tests.java

示例13: testBidResponseExample3VastXmlDocumentReturnedInline

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
@Test
  public void testBidResponseExample3VastXmlDocumentReturnedInline() throws IOException {
  	OpenRtbValidator validator = OpenRtbValidatorFactory.getValidator(OpenRtbInputType.BID_RESPONSE, OpenRtbVersion.V2_1);

// NOTE: IABs example is invalid due to:
  	// 1. "seatbid[0].bid.impid is required but missing
  	String invalidResource = "/v2_1/bid_responses/example3_vast_xml_document_returned_inline.json";
      ValidationResult invalidResult = validator.validate(JsonLoader.fromResource(invalidResource));

      logger.info("invalid validation result: " + invalidResult);
      assertFalse(invalidResource + " is valid", invalidResult.isValid());

String resource = "/v2_1/bid_responses/fixed/example3_vast_xml_document_returned_inline.json";
      ValidationResult result = validator.validate(JsonLoader.fromResource(resource));

      logger.info("validation result: " + result);
      assertTrue(resource + " is not valid", result.isValid());
  }
 
开发者ID:ad-tech-group,项目名称:openssp,代码行数:19,代码来源:OpenRtbValidatorV2_1Tests.java

示例14: checkSchema

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
private void checkSchema(File output)
{
    try
    {
        JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
        URL schemaPath = getClass().getResource("/swagger-schema.json");
        JsonSchema schema = factory.getJsonSchema(schemaPath.toString());
        JsonNode json = JsonLoader.fromFile(output);

        ProcessingReport report = schema.validate(json);
        System.out.println(report);
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:mauriciotogneri,项目名称:stewie,代码行数:18,代码来源:Stewie.java

示例15: isValid

import com.github.fge.jackson.JsonLoader; //导入依赖的package包/类
public static boolean isValid(String json, String schema) throws Exception {
    JsonNode schemaNode = JsonLoader.fromString(schema);       
    JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
    JsonSchema jsonSchema = factory.getJsonSchema(schemaNode); 
    JsonNode jsonNode = JsonLoader.fromString(json);
    ProcessingReport report = jsonSchema.validate(jsonNode);
    logger.debug("report: {}", report);
    return report.isSuccess();
}
 
开发者ID:intuit,项目名称:karate,代码行数:10,代码来源:SchemaUtils.java


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