public final class JacksonUtils extends Object
Modifier and Type | Field and Description |
---|---|
static com.fasterxml.jackson.databind.ObjectMapper |
OBJECT_MAPPER
A public static
ObjectMapper instance, so that they do not have to be instantiated all over the place,
as they are expensive to construct. |
Modifier and Type | Method and Description |
---|---|
static com.fasterxml.jackson.module.jsonSchema.JsonSchema |
schemaFor(Class<?> type)
Obtain the JsonSchema for a type, using the extended schema classes that are in this package.
|
static boolean |
validateJsonToSchema(String json,
com.fasterxml.jackson.module.jsonSchema.JsonSchema schema)
Validate that the provided JSON conforms to the schema.
|
public static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
ObjectMapper
instance, so that they do not have to be instantiated all over the place,
as they are expensive to construct. Note that the SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
option is disabled, so that dates will be in JSON Schema v4 format (e.g., "type":"string",
"format":"date-time").public static boolean validateJsonToSchema(String json, com.fasterxml.jackson.module.jsonSchema.JsonSchema schema) throws javax.validation.ValidationException
json
- JSON content.schema
- The schema. Must be an instance of one of the extended schema classes in this package.true
if schema implements ValidatableSchema
and was validated and false
otherwisejavax.validation.ValidationException
- If the JSON does not conform to the schema.public static com.fasterxml.jackson.module.jsonSchema.JsonSchema schemaFor(Class<?> type) throws com.fasterxml.jackson.databind.JsonMappingException
type
- The class to get a schema for.com.fasterxml.jackson.databind.JsonMappingException
- If the type cannot be mapped to a schema by Jackson.Copyright © 2010-2018, ForgeRock All Rights Reserved.