Package org.openmetadata.service.util
Class JsonUtils
- java.lang.Object
-
- org.openmetadata.service.util.JsonUtils
-
public final class JsonUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringENTITY_TYPE_ANNOTATIONstatic StringFIELD_TYPE_ANNOTATIONstatic StringJSON_FILE_EXTENSION
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.json.JsonValueapplyPatch(Object original, javax.json.JsonPatch patch)Applies the patch on original object and returns the updated objectstatic <T> TapplyPatch(T original, javax.json.JsonPatch patch, Class<T> clz)static booleanareEquals(Object obj1, Object obj2)Compared the canonicalized JSON representation of two object to check if they are equals or notstatic <T> TconvertValue(Object object, com.fasterxml.jackson.core.type.TypeReference<T> toValueTypeRef)static <T> TconvertValue(Object object, Class<T> clz)static TypegetEntityType(String jsonSchemaFile)Get all the fields types from the `definitions` section of a JSON schema file that are annotated with "$comment" field set to "@om-entity-type".static List<Type>getFieldTypes(String jsonSchemaFile)Get all the fields types from the `definitions` section of a JSON schema file that are annotated with "$comment" field set to "@om-field-type".static javax.json.JsonPatchgetJsonPatch(Object v1, Object v2)static javax.json.JsonPatchgetJsonPatch(String v1, String v2)static com.networknt.schema.JsonSchemagetJsonSchema(String schema)static javax.json.JsonStructuregetJsonStructure(Object o)static Map<String,Object>getMap(Object o)static com.fasterxml.jackson.databind.node.ObjectNodegetObjectNode()static com.fasterxml.jackson.databind.node.ObjectNodegetObjectNode(String key, com.fasterxml.jackson.databind.JsonNode value)static List<Type>getTypes()Get all the fields types and entity types from OpenMetadata JSON schema definition files.static booleanhasAnnotation(com.fasterxml.jackson.databind.JsonNode jsonNode, String annotation)static StringpojoToJson(Object o)static StringpojoToJson(Object o, boolean prettyPrint)static StringpojoToMaskedJson(Object entity)Serialize object removing all the fields annotated with @MaskedFieldstatic javax.json.JsonValuereadJson(String s)static <T> List<T>readObjects(String json, Class<T> clz)Read an array of objects of typeTfrom jsonstatic <T> List<T>readObjects(List<String> jsons, Class<T> clz)Read an object of typeTfrom jsonstatic com.fasterxml.jackson.databind.JsonNodereadTree(String extensionJson)static <T> TreadValue(String json, com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)static <T> TreadValue(String json, Class<T> clz)static <T> TtoExposedEntity(Object entity, Class<T> clazz)Serialize object removing all the fields annotated with @ExposedFieldstatic com.fasterxml.jackson.databind.JsonNodevalueToTree(Object object)
-
-
-
Field Detail
-
FIELD_TYPE_ANNOTATION
public static final String FIELD_TYPE_ANNOTATION
- See Also:
- Constant Field Values
-
ENTITY_TYPE_ANNOTATION
public static final String ENTITY_TYPE_ANNOTATION
- See Also:
- Constant Field Values
-
JSON_FILE_EXTENSION
public static final String JSON_FILE_EXTENSION
- See Also:
- Constant Field Values
-
-
Method Detail
-
getJsonStructure
public static javax.json.JsonStructure getJsonStructure(Object o)
-
readValue
public static <T> T readValue(String json, com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)
-
readObjects
public static <T> List<T> readObjects(String json, Class<T> clz)
Read an array of objects of typeTfrom json
-
readObjects
public static <T> List<T> readObjects(List<String> jsons, Class<T> clz)
Read an object of typeTfrom json
-
convertValue
public static <T> T convertValue(Object object, com.fasterxml.jackson.core.type.TypeReference<T> toValueTypeRef)
-
applyPatch
public static javax.json.JsonValue applyPatch(Object original, javax.json.JsonPatch patch)
Applies the patch on original object and returns the updated object
-
applyPatch
public static <T> T applyPatch(T original, javax.json.JsonPatch patch, Class<T> clz)
-
readJson
public static javax.json.JsonValue readJson(String s)
-
getJsonSchema
public static com.networknt.schema.JsonSchema getJsonSchema(String schema)
-
valueToTree
public static com.fasterxml.jackson.databind.JsonNode valueToTree(Object object)
-
hasAnnotation
public static boolean hasAnnotation(com.fasterxml.jackson.databind.JsonNode jsonNode, String annotation)
-
getTypes
public static List<Type> getTypes()
Get all the fields types and entity types from OpenMetadata JSON schema definition files.
-
getFieldTypes
public static List<Type> getFieldTypes(String jsonSchemaFile)
Get all the fields types from the `definitions` section of a JSON schema file that are annotated with "$comment" field set to "@om-field-type".
-
getEntityType
public static Type getEntityType(String jsonSchemaFile)
Get all the fields types from the `definitions` section of a JSON schema file that are annotated with "$comment" field set to "@om-entity-type".
-
pojoToMaskedJson
public static String pojoToMaskedJson(Object entity)
Serialize object removing all the fields annotated with @MaskedField
-
toExposedEntity
public static <T> T toExposedEntity(Object entity, Class<T> clazz)
Serialize object removing all the fields annotated with @ExposedField
-
getObjectNode
public static com.fasterxml.jackson.databind.node.ObjectNode getObjectNode(String key, com.fasterxml.jackson.databind.JsonNode value)
-
getObjectNode
public static com.fasterxml.jackson.databind.node.ObjectNode getObjectNode()
-
readTree
public static com.fasterxml.jackson.databind.JsonNode readTree(String extensionJson)
-
-