Class PropertyJsonUtil

java.lang.Object
com.inductiveautomation.perspective.common.util.PropertyJsonUtil

public class PropertyJsonUtil extends Object
  • Field Details

  • Method Details

    • decodeQualifiedValueJson

      @Nullable public static com.inductiveautomation.ignition.common.gson.JsonElement decodeQualifiedValueJson(com.inductiveautomation.ignition.common.gson.JsonElement element)

      Takes a JsonElement and if the element happens to be in in the Json serialized qualified value format used by Perspective, it returns an 'plain' or 'unencoded' object that is purely key:value representations of the qualified values.

      As an example, an object representing a simple value change in component 'props.interval' at path '0:0' may have the following QualityValue encoding that represents a change in a value within a object value node of a prop:

       {
         "0:0": {
           "props": {
             "$": ["map/merge"],
               "interval": {
                 "$": ["qv", 0, 303],
                 "$v": 100
               }
            }
          }
       }
       

      The decoded version would result in:

           {"0:0":{"props": {"interval": 100}}}
       
      Parameters:
      element - a non-null JsonElement
      Returns:
      a JsonElement stripped of meta and quality information, or null if
    • decodeQualifiedJsonObjectValue

      @Nullable public static com.inductiveautomation.ignition.common.gson.JsonElement decodeQualifiedJsonObjectValue(@Nonnull com.inductiveautomation.ignition.common.gson.JsonObject json)
      Recursively decodes a QV formatted JsonObject into a plain object containing the pure (non-meta info) values. If the object was a Qualfied"Plain" JsonObjects will be returned unaltered.
      Parameters:
      json - the json object to clean of quality and timestamp info
      Returns:
      cleaned JsonObject or null if no valid values or if parameter is null
    • decodeQualifiedJsonDatasetValue

      @Nullable public static com.inductiveautomation.ignition.common.gson.JsonElement decodeQualifiedJsonDatasetValue(@Nullable com.inductiveautomation.ignition.common.gson.JsonElement element)
      Returns a pure json representation of a Dataset if the element passed is a JsonObject who's node type code resolves to "ds" (key for dataset), and valid column values are determined. Otherwise returns original element, including null if original element was null..
      Parameters:
      element - a json element to decode as dataset. Or null.
      Returns:
      JsonArray representing dataset, original element if not a valid dataset, or, null element was null.
    • getAsString

      public static Optional<String> getAsString(@Nullable com.inductiveautomation.ignition.common.gson.JsonElement element)
      Returns:
      a string if the element is a JsonPrimitive and JsonPrimitive.isString() resolves to true, otherwise returns empty optional.
    • isStringValue

      public static boolean isStringValue(@Nullable com.inductiveautomation.ignition.common.gson.JsonElement element)
      Parameters:
      element - or null
      Returns:
      true if element is present and holds a primitive String value, otherwise false.