Class JsonUtils

java.lang.Object
test.de.iip_ecosphere.platform.transport.JsonUtils

public class JsonUtils extends Object
Utility methods for JSON serialization.
Author:
Holger Eichelberger, SSE
  • Constructor Details

    • JsonUtils

      public JsonUtils()
  • Method Details

    • readString

      public static String readString(org.json.simple.JSONObject obj, String field)
      Reads a string field from a JSON object.
      Parameters:
      obj - the object to read from
      field - the field to read from
      Returns:
      the string value or null
    • readDouble

      public static double readDouble(org.json.simple.JSONObject obj, String field, double dflt) throws IOException
      Reads a double field from a JSON object.
      Parameters:
      obj - the object to read from
      field - the field to read from
      dflt - the default value
      Returns:
      the double value, if not accessible dflt
      Throws:
      IOException - if parsing the double value fails
    • readInteger

      public static int readInteger(org.json.simple.JSONObject obj, String field, int dflt) throws IOException
      Reads an integer field from a JSON object.
      Parameters:
      obj - the object to read from
      field - the field to read from
      dflt - the default value
      Returns:
      the double value, if not accessible dflt
      Throws:
      IOException - if parsing the double value fails