Package com.bazaarvoice.jolt
Class Sortr
- java.lang.Object
-
- com.bazaarvoice.jolt.Sortr
-
- All Implemented Interfaces:
JoltTransform
,Transform
public class Sortr extends java.lang.Object implements Transform
Recursively sorts all maps within a JSON object into new sorted LinkedHashMaps so that serialized representations are deterministic. Useful for debugging and making test fixtures. Note this will make a copy of the input Map and List objects. The sort order is standard alphabetical ascending, with a special case for "~" prefixed keys to be bumped to the top.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Sortr.JsonKeyComparator
Standard alphabetical sort, with a special case for keys beginning with "~".
-
Field Summary
Fields Modifier and Type Field Description private static Sortr.JsonKeyComparator
jsonKeyComparator
-
Constructor Summary
Constructors Constructor Description Sortr()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.List<java.lang.Object>
ordered(java.util.List<java.lang.Object> list)
static java.lang.Object
sortJson(java.lang.Object obj)
private static java.util.Map<java.lang.String,java.lang.Object>
sortMap(java.util.Map<java.lang.String,java.lang.Object> map)
java.lang.Object
transform(java.lang.Object input)
Makes a "sorted" copy of the input JSON for human readability.
-
-
-
Field Detail
-
jsonKeyComparator
private static final Sortr.JsonKeyComparator jsonKeyComparator
-
-
Method Detail
-
transform
public java.lang.Object transform(java.lang.Object input)
Makes a "sorted" copy of the input JSON for human readability.
-
sortJson
public static java.lang.Object sortJson(java.lang.Object obj)
-
sortMap
private static java.util.Map<java.lang.String,java.lang.Object> sortMap(java.util.Map<java.lang.String,java.lang.Object> map)
-
ordered
private static java.util.List<java.lang.Object> ordered(java.util.List<java.lang.Object> list)
-
-