Class Sortr

java.lang.Object
com.bazaarvoice.jolt.Sortr
All Implemented Interfaces:
JoltTransform, Transform

public class Sortr extends 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.
  • Field Details

  • Constructor Details

    • Sortr

      public Sortr()
  • Method Details

    • transform

      public Object transform(Object input)
      Makes a "sorted" copy of the input JSON for human readability.
      Specified by:
      transform in interface Transform
      Parameters:
      input - the JSON object to transform, in plain vanilla Jackson Mapinvalid input: '<'String, Object> style
      Returns:
      the results of the transformation
    • sortJson

      public static Object sortJson(Object obj)
    • sortMap

      private static Map<String,Object> sortMap(Map<String,Object> map)
    • ordered

      private static List<Object> ordered(List<Object> list)