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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisJSONArray(InputStream stream) static booleanisJSONArray(Reader reader) static booleanisJSONArray(String content) static voidprintInfoTableToWriter(PrintWriter writer, InfoTable it) Deprecated.no replacementstatic voidprintJSON(PrintWriter writer, org.json.JSONObject jsonObject) static voidprintJSONFormatted(PrintWriter writer, org.json.JSONObject jsonObject) static org.json.JSONObjectreadJSON(InputStream stream) static org.json.JSONObjectstatic org.json.JSONObjectstatic org.json.JSONArrayreadJSONArray(InputStream input) static org.json.JSONArrayreadJSONArray(Reader reader) static org.json.JSONArrayreadJSONArray(String content) static ValueCollectionreadValueCollectionFromString(String jsonString, DataShapeDefinition dataShape) static voidvalidateJSON(String content) Validate the incoming string for JSON specification and leading and ending braces.static org.json.JSONObjectwrapJSONArray(org.json.JSONArray jsonArray) static StringDeprecated.no replacementstatic voidwriteInfoTableToWriter(Writer writer, InfoTable it) Deprecated.no replacementstatic StringwriteJSON(org.json.JSONObject jsonObject) static voidwriteJSON(org.json.JSONObject jsonObject, OutputStream stream) static voidstatic StringwriteJSONArray(org.json.JSONArray jsonArray) static StringwriteJSONFormatted(org.json.JSONObject jsonObject) static voidwriteJSONFormatted(org.json.JSONObject jsonObject, OutputStream stream) static voidwriteJSONFormatted(org.json.JSONObject jsonObject, Writer writer) static StringwriteValueCollectionToString(ValueCollection values, DataShapeDefinition dataShape) Deprecated.no replacement
-
Field Details
-
ARRAY_PROPERTY
- See Also:
-
-
Constructor Details
-
JSONUtilities
public JSONUtilities()Initializes this instace with default values.
-
-
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
-
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
-
writeJSONFormatted
@ThingworxExtensionApiMethod(since={6,6}) public static void writeJSONFormatted(org.json.JSONObject jsonObject, OutputStream stream) throws Exception - Throws:
Exception
-
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
-
writeJSON
@ThingworxExtensionApiMethod(since={6,6}) public static void writeJSON(org.json.JSONObject jsonObject, Writer writer) throws Exception - Throws:
Exception
-
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
-
printJSONFormatted
@ThingworxExtensionApiMethod(since={6,6}) public static void printJSONFormatted(PrintWriter writer, org.json.JSONObject jsonObject) throws Exception - Throws:
Exception
-
writeInfoTableToWriter
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static void writeInfoTableToWriter(Writer writer, InfoTable it) throws Exception Deprecated.no replacementWrites 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 replacementWrites 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 replacementReturns 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 replacementReturns 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
-
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.
-