Package com.dnanexus

Class DXJSON


  • public class DXJSON
    extends Object
    Utility class for working with JSON objects.
    • Method Detail

      • parseJson

        public static com.fasterxml.jackson.databind.JsonNode parseJson​(String stringified)
                                                                 throws IOException
        Parses the specified string into a JSON object.
        Throws:
        IOException
      • getArrayBuilder

        public static DXJSON.ArrayBuilder getArrayBuilder()
        Creates a new ArrayBuilder, initialized to produce an empty array.
      • getObjectBuilder

        public static DXJSON.ObjectBuilder getObjectBuilder()
        Creates a new ObjectBuilder, initialized to produce an empty object.
      • safeTreeToValue

        public static <T> T safeTreeToValue​(com.fasterxml.jackson.databind.JsonNode json,
                                            Class<T> valueType)
        Translates the given JSON object to an instance of the specified class.

        This is a wrapper around Jackson's treeToValue that suppresses JsonProcessingException and rethrows it as an unchecked exception.

        Parameters:
        json - JSON object
        valueType - A Jackson-deserializable class
        Returns:
        An instance of the class given by klass