Class JsonUnflattener

    • Constructor Detail

      • JsonUnflattener

        public JsonUnflattener​(String json)
        Creates a JSON unflattener by given JSON string.
        Parameters:
        json - a JSON string
      • JsonUnflattener

        public JsonUnflattener​(com.github.wnameless.json.base.JsonCore<?> jsonCore,
                               String json)
        Creates a JSON unflattener by given JsonCore and JSON string.
        Parameters:
        jsonCore - a JsonCore
        json - a JSON string
      • JsonUnflattener

        public JsonUnflattener​(Reader jsonReader)
                        throws IOException
        Creates a JSON unflattener by given JSON string reader.
        Parameters:
        jsonReader - a JSON reader
        Throws:
        IOException - if the jsonReader cannot be read
      • JsonUnflattener

        public JsonUnflattener​(com.github.wnameless.json.base.JsonCore<?> jsonCore,
                               Reader jsonReader)
                        throws IOException
        Creates a JSON unflattener by given JsonCore and JSON string reader.
        Parameters:
        jsonCore - a JsonCore
        jsonReader - a JSON reader
        Throws:
        IOException - if the jsonReader cannot be read
      • JsonUnflattener

        public JsonUnflattener​(Map<String,​?> flattenedMap)
        Creates a JSON unflattener by given flattened Map.
        Parameters:
        flattenedMap - a flattened Map
      • JsonUnflattener

        public JsonUnflattener​(com.github.wnameless.json.base.JsonCore<?> jsonCore,
                               Map<String,​?> flattenedMap)
        Creates a JSON unflattener by given JsonCore and flattened Map.
        Parameters:
        jsonCore - a JsonCore
        flattenedMap - a flattened Map
    • Method Detail

      • unflatten

        public static String unflatten​(String json)
        Returns a JSON string of nested objects by the given flattened JSON string.
        Parameters:
        json - a flattened JSON string
        Returns:
        a JSON string of nested objects
      • unflatten

        public static String unflatten​(Map<String,​?> flattenedMap)
        Returns a JSON string of nested objects by the given flattened Map.
        Parameters:
        flattenedMap - a flattened Map
        Returns:
        a JSON string of nested objects
      • unflattenAsMap

        public static Map<String,​Object> unflattenAsMap​(String json)
        Returns a Java Map of nested objects by the given flattened JSON string.
        Parameters:
        json - a flattened JSON string
        Returns:
        a Java Map of nested objects
      • unflattenAsMap

        public static Map<String,​Object> unflattenAsMap​(Map<String,​?> flattenedMap)
        Returns a Java Map of nested objects by the given flattened Map.
        Parameters:
        flattenedMap - a flattened Map
        Returns:
        a Java Map of nested objects
      • withSeparator

        public JsonUnflattener withSeparator​(char separator)
        A fluent setter to setup the separator within a key in the flattened JSON. The default separator is a dot(.).
        Parameters:
        separator - any character
        Returns:
        this JsonUnflattener
      • withLeftAndRightBrackets

        public JsonUnflattener withLeftAndRightBrackets​(char leftBracket,
                                                        char rightBracket)
        A fluent setter to setup the left and right brackets within a key in the flattened JSON. The default left and right brackets are left square bracket([) and right square bracket(]).
        Parameters:
        leftBracket - any character
        rightBracket - any character
        Returns:
        this JsonUnflattener
      • unflatten

        public String unflatten()
        Returns a JSON string of nested objects by the given flattened JSON string.
        Returns:
        a JSON string of nested objects
      • unflattenAsMap

        public Map<String,​Object> unflattenAsMap()
        Returns a Java Map of nested objects by the given flattened JSON string.
        Returns:
        a Java Map of nested objects
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object