Skip navigation links
Thingworx Platform API
9.0.0
com.thingworx.common.utils

Class JSONUtilities

  • java.lang.Object
    • com.thingworx.common.utils.JSONUtilities
    • Constructor Detail

      • JSONUtilities

        public JSONUtilities()
    • Method Detail

      • 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
      • 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 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
      • 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 writer
        it - 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 writer
        it - 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 ValueCollection
        dataShape - the DataShapeDefinition
        Returns:
        a String representation of the specified ValueCollection
        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.