Class JSONDataContainer

java.lang.Object
net.simplace.sim.io.interfaces.json.JSONDataContainer

public class JSONDataContainer extends Object
Wrapper around a Jackson JsonNode holding either a JSON array or a JSON object.
Author:
aenders
  • Constructor Details

    • JSONDataContainer

      public JSONDataContainer(com.fasterxml.jackson.databind.JsonNode aDataContainer)
      Wraps an existing node.
      Parameters:
      aDataContainer - the JSON node, may be null
  • 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:
      true if the data is a JSON array
    • isJSONObject

      public boolean isJSONObject()
      Returns:
      true if 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