Class JsonUtils


  • public final class JsonUtils
    extends Object
    • Method Detail

      • 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)
      • 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)
      • 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)
      • 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