Class PropertyJsonUtil
- java.lang.Object
-
- com.inductiveautomation.perspective.common.util.PropertyJsonUtil
-
public class PropertyJsonUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ARRAY_MERGE_TYPE
static java.lang.String
ARRAY_TYPE
static java.lang.String
ARRAY_VALUE_KEY
static java.lang.String
DATASET_VALUE_TYPE
static java.lang.String
MAP_MERGE_TYPE
static java.lang.String
MAP_TYPE
static java.lang.String
QUALITY_VALUE_TYPE
static java.lang.String
QV_VALUE_KEY
static java.lang.String
TIMESTAMP_VALUE_KEY
static java.lang.String
TIMESTAMP_VALUE_TYPE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.inductiveautomation.ignition.common.gson.JsonElement
decodeQualifiedJsonDatasetValue(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.static com.inductiveautomation.ignition.common.gson.JsonElement
decodeQualifiedJsonObjectValue(com.inductiveautomation.ignition.common.gson.JsonObject json)
Recursively decodes a QV formattedJsonObject
into a plain object containing the pure (non-meta info) values.static com.inductiveautomation.ignition.common.gson.JsonElement
decodeQualifiedValueJson(com.inductiveautomation.ignition.common.gson.JsonElement element)
Takes aJsonElement
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.static java.util.Optional<java.lang.String>
getAsString(com.inductiveautomation.ignition.common.gson.JsonElement element)
static boolean
isStringValue(com.inductiveautomation.ignition.common.gson.JsonElement element)
-
-
-
Field Detail
-
QUALITY_VALUE_TYPE
public static final java.lang.String QUALITY_VALUE_TYPE
- See Also:
- Constant Field Values
-
QV_VALUE_KEY
public static final java.lang.String QV_VALUE_KEY
- See Also:
- Constant Field Values
-
MAP_TYPE
public static final java.lang.String MAP_TYPE
- See Also:
- Constant Field Values
-
MAP_MERGE_TYPE
public static final java.lang.String MAP_MERGE_TYPE
- See Also:
- Constant Field Values
-
DATASET_VALUE_TYPE
public static final java.lang.String DATASET_VALUE_TYPE
- See Also:
- Constant Field Values
-
ARRAY_TYPE
public static final java.lang.String ARRAY_TYPE
- See Also:
- Constant Field Values
-
ARRAY_MERGE_TYPE
public static final java.lang.String ARRAY_MERGE_TYPE
- See Also:
- Constant Field Values
-
ARRAY_VALUE_KEY
public static final java.lang.String ARRAY_VALUE_KEY
- See Also:
- Constant Field Values
-
TIMESTAMP_VALUE_TYPE
public static final java.lang.String TIMESTAMP_VALUE_TYPE
- See Also:
- Constant Field Values
-
TIMESTAMP_VALUE_KEY
public static final java.lang.String TIMESTAMP_VALUE_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
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 formattedJsonObject
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 java.util.Optional<java.lang.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.
-
-