Class JsonUnflattener


  • public final class JsonUnflattener
    extends Object
    JsonUnflattener provides a static #unflatten(String) method to unflatten any flattened JSON string back to nested one.
    Author:
    Wei-Ming Wu
    • Constructor Detail

      • JsonUnflattener

        public JsonUnflattener​(org.bson.BsonValue json)
        Creates a JSON unflattener.
        Parameters:
        json -
    • Method Detail

      • unflatten

        public static org.bson.BsonValue unflatten​(org.bson.BsonValue 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
      • 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 org.bson.BsonValue unflatten()
        Returns a JSON string of nested objects by the given flattened JSON string.
        Returns:
        a JSON string of nested objects
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object