public class JsonTestUtil
extends java.lang.Object
JsonTestUtil
class provides common utilities used for executing tests that involve
Json.Constructor and Description |
---|
JsonTestUtil() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
parseJsonString(java.lang.String jsonString)
Parses a JSON string and returns either a List of Maps or a Map, depending on whether the JSON
represents an array or an object.
|
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
readNDJSON(byte[] jsonBytes)
Reads NDJSON (Newline Delimited JSON) data from a byte array and returns a list of parsed JSON
objects.
|
static java.util.Map<java.lang.String,java.lang.Object> |
readRecord(byte[] contents)
Read JSON record to a Map.
|
static java.util.Map<java.lang.String,java.lang.Object> |
readRecord(java.lang.String contents)
Read JSON record to a Map.
|
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
readRecords(byte[] contents)
Read JSON records to a list of Maps.
|
static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> |
readRecords(java.lang.String contents)
Read JSON records to a list of Maps.
|
static java.util.Map<java.lang.String,java.lang.Object> |
sortJsonMap(java.util.Map<java.lang.String,java.lang.Object> jsonMap)
Recursively sorts the keys of a nested JSON represented as a Map.
|
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> readRecords(byte[] contents) throws java.io.IOException
contents
- Byte array with contents to read.java.io.IOException
public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> readNDJSON(byte[] jsonBytes) throws java.io.IOException
jsonBytes
- A byte array containing NDJSON data.Map<String, Object>
.java.io.IOException
- if there's an issue reading or parsing the data.public static java.util.Map<java.lang.String,java.lang.Object> sortJsonMap(java.util.Map<java.lang.String,java.lang.Object> jsonMap)
jsonMap
- A Map<String, Object>
representing the nested JSON.Map<String, Object>
where the keys are sorted in natural order.public static java.util.List<java.util.Map<java.lang.String,java.lang.Object>> readRecords(java.lang.String contents) throws java.io.IOException
contents
- String with contents to read.java.io.IOException
public static java.util.Map<java.lang.String,java.lang.Object> readRecord(byte[] contents) throws java.io.IOException
contents
- Byte array with contents to read.java.io.IOException
public static java.util.Map<java.lang.String,java.lang.Object> readRecord(java.lang.String contents) throws java.io.IOException
contents
- String with contents to read.java.io.IOException
public static java.lang.Object parseJsonString(java.lang.String jsonString) throws java.io.IOException
jsonString
- The JSON string to parse.java.io.IOException
- If there's an error while parsing the JSON string.