/** * Parses a string and retruns a JSON tree */ public static JsonNode json(String s) throws IOException { return json(s, false); }
/** * Validate the given resource is a valid json schema. * * @param schemaResourceName * @throws ProcessingException * @throws IOException */ public void validateSchema(String schemaResourceName) throws ProcessingException, IOException { JsonUtils.loadSchema(schemaResourceName); }
/** * Pretty print a json doc */ public static String prettyPrint(JsonNode node) { StringBuilder bld = new StringBuilder(); prettyPrint(bld, node); return bld.toString(); }
/** * Verify the given document validates against the given schema. * * @param schemaResourceName * @param documentResourceName * @throws IOException * @throws ProcessingException */ public void runValidJsonTest(String schemaResourceName, String documentResourceName) throws IOException, ProcessingException { JsonSchema schema = JsonUtils.loadSchema(schemaResourceName); JsonNode instance = loadJsonNode(documentResourceName); // if report isn't null it's a failure and the value of report is the detail of why String report = JsonUtils.jsonSchemaValidation(schema, instance); Assert.assertTrue("Expected validation to succeed!\nResource: " + documentResourceName + "\nMessages:\n" + report, report == null); } }
@Override public int size(Response response) { return JsonUtils.size(response.getEntityData()); }
LOGGER.debug("validating {}",clazz); try { String validationErrors=JsonUtils.jsonSchemaValidation(t.getSchema(),node); if(validationErrors!=null) { throw Error.get(ConfigConstants.ERR_VALIDATION_FAILED,validationErrors);
/** * Utility method to convert array of strings to a json document. * * @param strings * @return */ public static String toJson(String[] strings) { return _toJson(strings); }
/** * Verify the given document validates against the given schema. * * @param schemaResourceName * @param documentResourceName * @throws IOException * @throws ProcessingException */ public void runValidJsonTest(String schemaResourceName, String documentResourceName) throws IOException, ProcessingException { JsonSchema schema = JsonUtils.loadSchema(schemaResourceName); JsonNode instance = loadJsonNode(documentResourceName); // if report isn't null it's a failure and the value of report is the detail of why String report = JsonUtils.jsonSchemaValidation(schema, instance); if (report != null) { Assert.fail("Expected validation to succeed! Resource: " + documentResourceName + " Messages: " + report.replaceAll("\n", " ")); } } }
public static int size(TranslatedDoc doc) { return JsonUtils.size(doc.doc.getRoot()); }
LOGGER.debug("validating {}", clazz); try { String validationErrors = JsonUtils.jsonSchemaValidation(t.getSchema(), node); if (validationErrors != null) { throw Error.get(ConfigConstants.ERR_VALIDATION_FAILED, validationErrors);
/** * Utility method to convert array of strings to a json document. * * @param strings * @return */ public static String toJson(String[] strings) { return _toJson(strings); }
/** * Parses a JSON stream */ public static JsonNode json(Reader reader) throws IOException { return json(reader, false); }
/** * Verify the given document validates against the given schema. * * @param schemaResourceName * @param documentResourceName * @throws IOException * @throws ProcessingException */ public void runValidJsonTest(String schemaResourceName, String documentResourceName) throws IOException, ProcessingException { JsonSchema schema = JsonUtils.loadSchema(schemaResourceName); JsonNode instance = loadJsonNode(documentResourceName); // if report isn't null it's a failure and the value of report is the detail of why String report = JsonUtils.jsonSchemaValidation(schema, instance); if (report != null) { Assert.fail("Expected validation to succeed! Resource: " + documentResourceName + " Messages: " + report.replaceAll("\n", " ")); } } }
@Override public int size(Response response) { return JsonUtils.size(response.getEntityData()); }
/** * Validate the given resource is a valid json schema. * * @param schemaResourceName * @throws ProcessingException * @throws IOException */ public void validateSchema(String schemaResourceName) throws ProcessingException, IOException { JsonUtils.loadSchema(schemaResourceName); }
LOGGER.debug("validating {}", clazz); try { String validationErrors = JsonUtils.jsonSchemaValidation(t.getSchema(), node); if (validationErrors != null) { throw Error.get(ConfigConstants.ERR_VALIDATION_FAILED, validationErrors);
/** * Pretty print a json doc */ public static String prettyPrint(JsonNode node) { StringBuilder bld = new StringBuilder(); prettyPrint(bld, node); return bld.toString(); }
/** * Utility method to convert array of strings to a json document. * * @param strings * @return */ public static String toJson(String[] strings) { return _toJson(strings); }
/** * Parses a JSON stream */ public static JsonNode json(Reader reader) throws IOException { return json(reader, false); }
public static int size(JsonDoc doc) { return JsonUtils.size(doc.getRoot()); }