Package org.restheart.utils
Class JsonUnflattener
- java.lang.Object
-
- org.restheart.utils.JsonUnflattener
-
public final class JsonUnflattener extends Object
JsonUnflattenerprovides a static#unflatten(String)method to unflatten any flattened JSON string back to nested one.- Author:
- Wei-Ming Wu
-
-
Constructor Summary
Constructors Constructor Description JsonUnflattener(org.bson.BsonValue json)Creates a JSON unflattener.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)inthashCode()StringtoString()org.bson.BsonValueunflatten()Returns a JSON string of nested objects by the given flattened JSON string.static org.bson.BsonValueunflatten(org.bson.BsonValue json)Returns a JSON string of nested objects by the given flattened JSON string.JsonUnflattenerwithLeftAndRightBrackets(char leftBracket, char rightBracket)A fluent setter to setup the left and right brackets within a key in the flattened JSON.JsonUnflattenerwithSeparator(char separator)A fluent setter to setup the separator within a key in the flattened 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 characterrightBracket- 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
-
-