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 java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ARRAY_PROPERTY
-
Constructor Summary
Constructors Constructor Description JSONUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static boolean
isJSONArray(java.io.InputStream stream)
static boolean
isJSONArray(java.io.Reader reader)
static boolean
isJSONArray(java.lang.String content)
static void
printInfoTableToWriter(java.io.PrintWriter writer, InfoTable it)
Deprecated.no replacementstatic void
printJSON(java.io.PrintWriter writer, org.json.JSONObject jsonObject)
static void
printJSONFormatted(java.io.PrintWriter writer, org.json.JSONObject jsonObject)
static org.json.JSONObject
readJSON(java.io.InputStream stream)
static org.json.JSONObject
readJSON(java.io.Reader reader)
static org.json.JSONObject
readJSON(java.lang.String content)
static org.json.JSONArray
readJSONArray(java.io.InputStream input)
static org.json.JSONArray
readJSONArray(java.io.Reader reader)
static org.json.JSONArray
readJSONArray(java.lang.String content)
static ValueCollection
readValueCollectionFromString(java.lang.String jsonString, DataShapeDefinition dataShape)
static void
validateJSON(java.lang.String content)
Validate the incoming string for JSON specification and leading and ending braces.static org.json.JSONObject
wrapJSONArray(org.json.JSONArray jsonArray)
static java.lang.String
writeInfoTableToString(InfoTable it)
Deprecated.no replacementstatic void
writeInfoTableToWriter(java.io.Writer writer, InfoTable it)
Deprecated.no replacementstatic java.lang.String
writeJSON(org.json.JSONObject jsonObject)
static void
writeJSON(org.json.JSONObject jsonObject, java.io.OutputStream stream)
static void
writeJSON(org.json.JSONObject jsonObject, java.io.Writer writer)
static java.lang.String
writeJSONArray(org.json.JSONArray jsonArray)
static java.lang.String
writeJSONFormatted(org.json.JSONObject jsonObject)
static void
writeJSONFormatted(org.json.JSONObject jsonObject, java.io.OutputStream stream)
static void
writeJSONFormatted(org.json.JSONObject jsonObject, java.io.Writer writer)
static java.lang.String
writeValueCollectionToString(ValueCollection values, DataShapeDefinition dataShape)
Deprecated.no replacement
-
-
-
Field Detail
-
ARRAY_PROPERTY
public static final java.lang.String ARRAY_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
isJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static boolean isJSONArray(java.lang.String content)
-
isJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static boolean isJSONArray(java.io.InputStream stream)
-
isJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static boolean isJSONArray(java.io.Reader reader)
-
readJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONArray readJSONArray(java.lang.String content)
-
readJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONArray readJSONArray(java.io.InputStream input)
-
readJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONArray readJSONArray(java.io.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(java.lang.String content)
-
readJSON
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONObject readJSON(java.io.InputStream stream)
-
readJSON
@ThingworxExtensionApiMethod(since={6,6}) public static org.json.JSONObject readJSON(java.io.Reader reader)
-
writeJSONFormatted
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.String writeJSONFormatted(org.json.JSONObject jsonObject)
-
writeJSONFormatted
@ThingworxExtensionApiMethod(since={6,6}) public static void writeJSONFormatted(org.json.JSONObject jsonObject, java.io.Writer writer) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
writeJSONFormatted
@ThingworxExtensionApiMethod(since={6,6}) public static void writeJSONFormatted(org.json.JSONObject jsonObject, java.io.OutputStream stream) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
writeJSON
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.String writeJSON(org.json.JSONObject jsonObject)
-
writeJSON
@ThingworxExtensionApiMethod(since={6,6}) public static void writeJSON(org.json.JSONObject jsonObject, java.io.OutputStream stream) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
writeJSON
@ThingworxExtensionApiMethod(since={6,6}) public static void writeJSON(org.json.JSONObject jsonObject, java.io.Writer writer) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
writeJSONArray
@ThingworxExtensionApiMethod(since={6,6}) public static java.lang.String writeJSONArray(org.json.JSONArray jsonArray)
-
printJSON
@ThingworxExtensionApiMethod(since={6,6}) public static void printJSON(java.io.PrintWriter writer, org.json.JSONObject jsonObject) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
printJSONFormatted
@ThingworxExtensionApiMethod(since={6,6}) public static void printJSONFormatted(java.io.PrintWriter writer, org.json.JSONObject jsonObject) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
writeInfoTableToWriter
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static void writeInfoTableToWriter(java.io.Writer writer, InfoTable it) throws java.lang.Exception
Deprecated.no replacement
Writes the specified InfoTable to the specified writer.- Parameters:
writer
- the writerit
- the InfoTable- Throws:
java.lang.Exception
- if an exception occurs
-
printInfoTableToWriter
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static void printInfoTableToWriter(java.io.PrintWriter writer, InfoTable it) throws java.lang.Exception
Deprecated.no replacement
Writes the specified InfoTable to the specified writer.- Parameters:
writer
- the writerit
- the InfoTable- Throws:
java.lang.Exception
- if an exception occurs
-
writeInfoTableToString
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static java.lang.String writeInfoTableToString(InfoTable it) throws java.lang.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:
java.lang.Exception
- if an error occurs
-
writeValueCollectionToString
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static java.lang.String writeValueCollectionToString(ValueCollection values, DataShapeDefinition dataShape) throws java.lang.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:
java.lang.Exception
- if an error occurs
-
readValueCollectionFromString
@ThingworxExtensionApiMethod(since={6,6}) public static ValueCollection readValueCollectionFromString(java.lang.String jsonString, DataShapeDefinition dataShape) throws java.lang.Exception
- Throws:
java.lang.Exception
- If an error occurs
-
validateJSON
@ThingworxExtensionApiMethod(since={7,2,0}) public static void validateJSON(java.lang.String content) throws java.lang.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:
java.lang.Exception
- When the provided string is found to be invalid. This exception's message can be used for error reporting.
-
-