Package com.thingworx.common.utils
Class JSONUtilities
java.lang.Object
com.thingworx.common.utils.JSONUtilities
@ThingworxExtensionApiClass(since={6,6},
canInstantiate=true)
public final class JSONUtilities
extends Object
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isJSONArray
(InputStream stream) static boolean
isJSONArray
(Reader reader) static boolean
isJSONArray
(String content) static void
printInfoTableToWriter
(PrintWriter writer, InfoTable it) Deprecated.no replacementstatic void
printJSON
(PrintWriter writer, org.json.JSONObject jsonObject) static void
printJSONFormatted
(PrintWriter writer, org.json.JSONObject jsonObject) static org.json.JSONObject
readJSON
(InputStream stream) static org.json.JSONObject
static org.json.JSONObject
static org.json.JSONArray
readJSONArray
(InputStream input) static org.json.JSONArray
readJSONArray
(Reader reader) static org.json.JSONArray
readJSONArray
(String content) static ValueCollection
readValueCollectionFromString
(String jsonString, DataShapeDefinition dataShape) static void
validateJSON
(String content)
Validate the incoming string for JSON specification and leading and ending braces.static org.json.JSONObject
wrapJSONArray
(org.json.JSONArray jsonArray) static String
Deprecated.no replacementstatic void
writeInfoTableToWriter
(Writer writer, InfoTable it) Deprecated.no replacementstatic String
writeJSON
(org.json.JSONObject jsonObject) static void
writeJSON
(org.json.JSONObject jsonObject, OutputStream stream) static void
static String
writeJSONArray
(org.json.JSONArray jsonArray) static String
writeJSONFormatted
(org.json.JSONObject jsonObject) static void
writeJSONFormatted
(org.json.JSONObject jsonObject, OutputStream stream) static void
writeJSONFormatted
(org.json.JSONObject jsonObject, Writer writer) static String
writeValueCollectionToString
(ValueCollection values, DataShapeDefinition dataShape) Deprecated.no replacement
-
Field Details
-
ARRAY_PROPERTY
- See Also:
-
-
Constructor Details
-
JSONUtilities
public JSONUtilities()
-
-
Method Details
-
isJSONArray
-
isJSONArray
-
isJSONArray
-
readJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONArray readJSONArray(String content) -
readJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONArray readJSONArray(InputStream input) -
readJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONArray readJSONArray(Reader reader) -
wrapJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONObject wrapJSONArray(org.json.JSONArray jsonArray) throws org.json.JSONException - Throws:
org.json.JSONException
- If an error occurs
-
readJSON
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONObject readJSON(String content) -
readJSON
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONObject readJSON(InputStream stream) -
readJSON
-
writeJSONFormatted
@ThingworxExtensionApiMethod(since={6,6}) public static String writeJSONFormatted(org.json.JSONObject jsonObject) -
writeJSONFormatted
@ThingworxExtensionApiMethod(since={6,6}) public static void writeJSONFormatted(org.json.JSONObject jsonObject, Writer writer) throws Exception - Throws:
Exception
- If an error occurs
-
writeJSONFormatted
@ThingworxExtensionApiMethod(since={6,6}) public static void writeJSONFormatted(org.json.JSONObject jsonObject, OutputStream stream) throws Exception - Throws:
Exception
- If an error occurs
-
writeJSON
@ThingworxExtensionApiMethod(since={6,6}) public static String writeJSON(org.json.JSONObject jsonObject) -
writeJSON
@ThingworxExtensionApiMethod(since={6,6}) public static void writeJSON(org.json.JSONObject jsonObject, OutputStream stream) throws Exception - Throws:
Exception
- If an error occurs
-
writeJSON
@ThingworxExtensionApiMethod(since={6,6}) public static void writeJSON(org.json.JSONObject jsonObject, Writer writer) throws Exception - Throws:
Exception
- If an error occurs
-
writeJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static String writeJSONArray(org.json.JSONArray jsonArray) -
printJSON
@ThingworxExtensionApiMethod(since={6,6}) public static void printJSON(PrintWriter writer, org.json.JSONObject jsonObject) throws Exception - Throws:
Exception
- If an error occurs
-
printJSONFormatted
@ThingworxExtensionApiMethod(since={6,6}) public static void printJSONFormatted(PrintWriter writer, org.json.JSONObject jsonObject) throws Exception - Throws:
Exception
- If an error occurs
-
writeInfoTableToWriter
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static void writeInfoTableToWriter(Writer writer, InfoTable it) throws Exception Deprecated.no replacement
Writes the specified InfoTable to the specified writer.- Parameters:
writer
- the writerit
- the InfoTable- Throws:
Exception
- if an exception occurs
-
printInfoTableToWriter
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static void printInfoTableToWriter(PrintWriter writer, InfoTable it) throws Exception Deprecated.no replacement
Writes the specified InfoTable to the specified writer.- Parameters:
writer
- the writerit
- the InfoTable- Throws:
Exception
- if an exception occurs
-
writeInfoTableToString
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static String writeInfoTableToString(InfoTable it) throws Exception Deprecated.no replacement
Returns a String representation of the specified InfoTable.- Parameters:
it
- the InfoTable- Returns:
- a String representation of the specified InfoTable
- Throws:
Exception
- if an error occurs
-
writeValueCollectionToString
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static String writeValueCollectionToString(ValueCollection values, DataShapeDefinition dataShape) throws Exception Deprecated.no replacement
Returns a String representation of the specified ValueCollection, where the returned value contains only the values defined within the specified DataShapeDefinition.- Parameters:
values
- the ValueCollectiondataShape
- the DataShapeDefinition- Returns:
- a String representation of the specified ValueCollection
- Throws:
Exception
- if an error occurs
-
readValueCollectionFromString
@ThingworxExtensionApiMethod(since={6,6}) public static ValueCollection readValueCollectionFromString(String jsonString, DataShapeDefinition dataShape) throws Exception - Throws:
Exception
- If an error occurs
-
validateJSON
@ThingworxExtensionApiMethod(since={7,2,0}) public static void validateJSON(String content) throws Exception
Validate the incoming string for JSON specification and leading and ending braces. Can be used for both JSON objects and arrays.- Parameters:
content
- - String representation of the JSON to validate- Throws:
Exception
- When the provided string is found to be invalid. This exception's message can be used for error reporting.
-