Class JsonUtils

java.lang.Object
org.openmetadata.service.util.JsonUtils

public final class JsonUtils extends Object
  • Field Details

  • Method Details

    • pojoToJson

      public static String pojoToJson(Object o)
    • pojoToJson

      public static String pojoToJson(Object o, boolean prettyPrint)
    • getJsonStructure

      public static javax.json.JsonStructure getJsonStructure(Object o)
    • getMap

      public static Map<String,Object> getMap(Object o)
    • readOrConvertValue

      public static <T> T readOrConvertValue(Object obj, Class<T> clz)
    • readOrConvertValues

      public static <T> List<T> readOrConvertValues(Object obj, Class<T> clz)
    • readValue

      public static <T> T readValue(String json, String clazzName)
    • readValue

      public static <T> T readValue(String json, Class<T> clz)
    • readValue

      public static <T> T readValue(String json, com.fasterxml.jackson.core.type.TypeReference<T> valueTypeRef)
    • convertObjects

      public static <T> List<T> convertObjects(Object json, Class<T> clz)
      Convert an array of objects of type T from json
    • readObjects

      public static <T> List<T> readObjects(String json, Class<T> clz)
      Read an array of objects of type T from json
    • readObjects

      public static <T> List<T> readObjects(List<String> jsons, Class<T> clz)
      Read an object of type T from json
    • convertValue

      public static <T> T convertValue(Object object, Class<T> clz)
    • 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)
    • getJsonPatch

      public static javax.json.JsonPatch getJsonPatch(String v1, String v2)
    • getJsonPatch

      public static javax.json.JsonPatch getJsonPatch(Object v1, Object v2)
    • 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)
    • treeToValue

      public static <T> T treeToValue(com.fasterxml.jackson.databind.JsonNode jsonNode, Class<T> classType)
    • areEquals

      public static boolean areEquals(Object obj1, Object obj2)
      Compared the canonicalized JSON representation of two object to check if they are equals or not
    • deepCopy

      public static <T> T deepCopy(T original, Class<T> clazz)
    • extractValue

      public static <T> T extractValue(String jsonResponse, String... keys)
    • extractValue

      public static <T> T extractValue(com.fasterxml.jackson.databind.JsonNode jsonNode, String... keys)
    • validateJsonSchema

      public static <T> void validateJsonSchema(Object fromValue, Class<T> toValueType)
      Validates the JSON structure against a Java class schema. This method is specifically designed to handle and validate complex JSON data that includes nested JSON objects, addressing limitations of earlier validation methods which did not support nested structures.