Package com.dnanexus
Class DXJSON
- java.lang.Object
-
- com.dnanexus.DXJSON
-
public class DXJSON extends Object
Utility class for working with JSON objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDXJSON.ArrayBuilderBuilder class that generates a JSON array.static classDXJSON.ObjectBuilderBuilder class that generates a JSON object (hash).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DXJSON.ArrayBuildergetArrayBuilder()Creates a new ArrayBuilder, initialized to produce an empty array.static DXJSON.ObjectBuildergetObjectBuilder()Creates a new ObjectBuilder, initialized to produce an empty object.static com.fasterxml.jackson.databind.JsonNodeparseJson(String stringified)Parses the specified string into a JSON object.static <T> TsafeTreeToValue(com.fasterxml.jackson.databind.JsonNode json, Class<T> valueType)Translates the given JSON object to an instance of the specified class.
-
-
-
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
treeToValuethat suppressesJsonProcessingExceptionand rethrows it as an unchecked exception.- Parameters:
json- JSON objectvalueType- A Jackson-deserializable class- Returns:
- An instance of the class given by
klass
-
-