本文整理匯總了Java中com.github.fge.jsonschema.core.report.ProcessingReport.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java ProcessingReport.toString方法的具體用法?Java ProcessingReport.toString怎麽用?Java ProcessingReport.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.github.fge.jsonschema.core.report.ProcessingReport
的用法示例。
在下文中一共展示了ProcessingReport.toString方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validateSchema
import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的package包/類
private JsonSchema validateSchema(JsonNode jsonSchema)
throws UnRAVLException {
try {
final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
final JsonSchema schema = factory.getJsonSchema(jsonSchema);
SyntaxValidator syntaxValidator = factory.getSyntaxValidator();
if (!syntaxValidator.schemaIsValid(jsonSchema)) {
throw new UnRAVLException("JSON schema is invalid");
}
ProcessingReport report = syntaxValidator
.validateSchema(jsonSchema);
boolean success = report.isSuccess();
if (!success) {
throw new UnRAVLAssertionException(report.toString());
}
return schema;
} catch (ProcessingException e) {
throw new UnRAVLException(e);
}
}
示例2: valdate
import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的package包/類
@Override
public boolean valdate(final IActivityLogger aLogger,
final CJsonSchema aSchema, final JSONObject aData) throws Exception {
// validate json
try {
aLogger.logDebug(this, "getSchema",
"create JsonNode fro JSONObject for the data");
ObjectMapper wMapper = new ObjectMapper();
JsonNode wJson = wMapper.readTree(aData.toString());
aLogger.logDebug(this, "getSchema", "validate data with schema");
ProcessingReport wReport = aSchema.getSchema()
.validate(wJson, true);
if (wReport.isSuccess()) {
return true;
} else {
throw new SchemaException("ERROR; failed schema validation ! ["
+ wReport.toString() + "] ");
}
} catch (Exception e) {
throw new SchemaException(e, e.getMessage());
}
}
示例3: getValidationResult
import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的package包/類
private final ValidationResult getValidationResult(JsonNode jsonNode) throws IOException {
try {
ProcessingReport processingReport = schema.validate(jsonNode);
if (processingReport != null) {
return new ValidationResult(processingReport.isSuccess(), processingReport.toString());
} else {
return new ValidationResult(false, null);
}
} catch (ProcessingException e) {
throw new IOException(e.getMessage());
}
}
示例4: validate
import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的package包/類
@Override
public void validate(Object value) throws ValidationFailedException {
JsonNode valueNode = _objectMapper.valueToTree(value);
try {
ProcessingReport report = _schema.validate(valueNode);
if (!report.isSuccess()) {
throw new ValidationFailedException("Validation of data failed: " + report.toString());
}
} catch (ProcessingException e) {
throw new ValidationFailedException("Validation of data failed: " + e.getMessage());
}
}
示例5: validate
import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的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);
}
}
}
示例6: validateValueAgainstSchema
import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的package包/類
private void validateValueAgainstSchema(JsonNode node, JsonSchema schema)
throws UnRAVLException {
try {
ProcessingReport report = schema.validate(node, true);
boolean success = report.isSuccess();
if (!success) {
throw new UnRAVLAssertionException(report.toString());
}
} catch (ProcessingException e) {
throw new UnRAVLException(e);
}
}