當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonSchemaFactory.getValidator方法代碼示例

本文整理匯總了Java中com.github.fge.jsonschema.main.JsonSchemaFactory.getValidator方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonSchemaFactory.getValidator方法的具體用法?Java JsonSchemaFactory.getValidator怎麽用?Java JsonSchemaFactory.getValidator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.fge.jsonschema.main.JsonSchemaFactory的用法示例。


在下文中一共展示了JsonSchemaFactory.getValidator方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testDefaultConfig

import com.github.fge.jsonschema.main.JsonSchemaFactory; //導入方法依賴的package包/類
@Test
public final void testDefaultConfig()
throws Exception {
	final ObjectMapper m = new ObjectMapper()
		.configure(JsonParser.Feature.ALLOW_COMMENTS, true)
		.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
	final JsonNode jsonInput = m.readTree(
		Paths.get(PathUtil.getBaseDir(), "config", "defaults.json").toFile()
	);
	final JsonNode jsonSchema = m.readTree(
		Paths.get(PathUtil.getBaseDir(), "config", "config-schema.json").toFile()
	);
	final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
	final JsonValidator validator = factory.getValidator();
	final ProcessingReport report = validator.validate(jsonSchema, jsonInput);
	assertTrue(report.toString(), report.isSuccess());
}
 
開發者ID:emc-mongoose,項目名稱:mongoose-base,代碼行數:18,代碼來源:ValidateConfigTest.java

示例2: testAllScenarios

import com.github.fge.jsonschema.main.JsonSchemaFactory; //導入方法依賴的package包/類
@Test
public final void testAllScenarios()
throws Exception {

	final ObjectMapper m = new ObjectMapper()
		.configure(JsonParser.Feature.ALLOW_COMMENTS, true)
		.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
	final JsonNode jsonSchema = m.readTree(
		Paths.get(PathUtil.getBaseDir(), DIR_EXAMPLE_SCENARIO, "json", "schema.json").toFile()
	);
	final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
	final JsonValidator validator = factory.getValidator();

	final List<Path> scenarioPaths = Files
		.walk(Paths.get(PathUtil.getBaseDir(), DIR_EXAMPLE_SCENARIO, "json"))
		.filter(path -> path.toString().endsWith(".json"))
		.filter(path -> !path.endsWith("schema.json") && !path.endsWith("invalid.json"))
		.collect(Collectors.toList());

	JsonNode nextScenario;
	ProcessingReport report;
	for(final Path nextScenarioPath : scenarioPaths) {
		if(!nextScenarioPath.toString().contains("compat")) {
			System.out.println("Validating the scenario file: " + nextScenarioPath.toString());
			nextScenario = m.readTree(nextScenarioPath.toFile());
			report = validator.validate(jsonSchema, nextScenario);
			assertTrue(report.toString(), report.isSuccess());
		}
	}
}
 
開發者ID:emc-mongoose,項目名稱:mongoose-base,代碼行數:31,代碼來源:ValidateScenariosTest.java

示例3: validateJsonData

import com.github.fge.jsonschema.main.JsonSchemaFactory; //導入方法依賴的package包/類
protected boolean validateJsonData(final String jsonSchema, final String jsonData) throws Exception {
	final JsonNode d = JsonLoader.fromString(jsonData);
	final JsonNode s = JsonLoader.fromString(jsonSchema);

	final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
	JsonValidator v = factory.getValidator();

	ProcessingReport report = v.validate(s, d);

	return report.toString().contains("success");
}
 
開發者ID:apache,項目名稱:metron,代碼行數:12,代碼來源:CEFParserTest.java

示例4: validateJsonData

import com.github.fge.jsonschema.main.JsonSchemaFactory; //導入方法依賴的package包/類
/**
 * validateJsonData
 * @param jsonSchema
 * @param jsonData
 * @return
 * @throws Exception
 */
 
protected boolean validateJsonData(final String jsonSchema, final String jsonData)
    throws Exception {
    
    final JsonNode d = JsonLoader.fromString(jsonData);
    final JsonNode s = JsonLoader.fromString(jsonSchema);
    
    final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
    JsonValidator v = factory.getValidator();
    
    ProcessingReport report = v.validate(s, d);
    System.out.println(report);
    
    return report.toString().contains("success");
}
 
開發者ID:OpenSOC,項目名稱:opensoc-streaming,代碼行數:23,代碼來源:AbstractConfigTest.java

示例5: validateJsonData

import com.github.fge.jsonschema.main.JsonSchemaFactory; //導入方法依賴的package包/類
protected boolean validateJsonData(final String jsonSchema, final String jsonData)
    throws IOException, ProcessingException {

  final JsonNode d = JsonLoader.fromString(jsonData);
  final JsonNode s = JsonLoader.fromString(jsonSchema);

  final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
  JsonValidator v = factory.getValidator();

  ProcessingReport report = v.validate(s, d);

  return report.toString().contains("success");
}
 
開發者ID:apache,項目名稱:metron,代碼行數:14,代碼來源:AbstractParserConfigTest.java


注:本文中的com.github.fge.jsonschema.main.JsonSchemaFactory.getValidator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。