Class JsonUtils
java.lang.Object
test.de.iip_ecosphere.platform.transport.JsonUtils
Utility methods for JSON serialization.
- Author:
- Holger Eichelberger, SSE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublereadDouble(org.json.simple.JSONObject obj, String field, double dflt) Reads a double field from a JSON object.static intreadInteger(org.json.simple.JSONObject obj, String field, int dflt) Reads an integer field from a JSON object.static StringreadString(org.json.simple.JSONObject obj, String field) Reads a string field from a JSON object.
-
Constructor Details
-
JsonUtils
public JsonUtils()
-
-
Method Details
-
readString
Reads a string field from a JSON object.- Parameters:
obj- the object to read fromfield- 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 fromfield- the field to read fromdflt- 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 fromfield- the field to read fromdflt- the default value- Returns:
- the double value, if not accessible
dflt - Throws:
IOException- if parsing the double value fails
-