Class JSONDataContainer
java.lang.Object
net.simplace.sim.io.interfaces.json.JSONDataContainer
Wrapper around a Jackson
JsonNode holding either a JSON array or a JSON object.- Author:
- aenders
-
Constructor Summary
ConstructorsConstructorDescriptionJSONDataContainer(com.fasterxml.jackson.databind.JsonNode aDataContainer) Wraps an existing node. -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.JsonNodegetArray()com.fasterxml.jackson.databind.JsonNodebooleanbooleanstatic JSONDataContainer
-
Constructor Details
-
JSONDataContainer
public JSONDataContainer(com.fasterxml.jackson.databind.JsonNode aDataContainer) Wraps an existing node.- Parameters:
aDataContainer- the JSON node, may benull
-
-
Method Details
-
parse
public static JSONDataContainer parse(String aJSONString) throws com.fasterxml.jackson.core.JsonProcessingException - Parameters:
aJSONString- the JSON string- Returns:
- the container with the parsed data
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if the string is no valid JSON
-
isJSONArray
public boolean isJSONArray()- Returns:
trueif the data is a JSON array
-
isJSONObject
public boolean isJSONObject()- Returns:
trueif the data is a JSON object
-
getArray
public com.fasterxml.jackson.databind.JsonNode getArray()- Returns:
- the data if it is a JSON array, otherwise
null
-
getObject
public com.fasterxml.jackson.databind.JsonNode getObject()- Returns:
- the data if it is a JSON object, otherwise
null
-