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.StringARRAY_MERGE_TYPEstatic java.lang.StringARRAY_TYPEstatic java.lang.StringARRAY_VALUE_KEYstatic java.lang.StringDATASET_VALUE_TYPEstatic java.lang.StringMAP_MERGE_TYPEstatic java.lang.StringMAP_TYPEstatic java.lang.StringQUALITY_VALUE_TYPEstatic java.lang.StringQV_VALUE_KEY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.inductiveautomation.ignition.common.gson.JsonElementdecodeQualifiedJsonDatasetValue(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.JsonElementdecodeQualifiedJsonObjectValue(com.inductiveautomation.ignition.common.gson.JsonObject json)Recursively decodes a QV formattedJsonObjectinto a plain object containing the pure (non-meta info) values.static com.inductiveautomation.ignition.common.gson.JsonElementdecodeQualifiedValueJson(com.inductiveautomation.ignition.common.gson.JsonElement element)Takes aJsonElementand 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 booleanisStringValue(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
-
-
Method Detail
-
decodeQualifiedValueJson
@Nullable public static com.inductiveautomation.ignition.common.gson.JsonElement decodeQualifiedValueJson(com.inductiveautomation.ignition.common.gson.JsonElement element)
Takes a
JsonElementand 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 formattedJsonObjectinto 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.
-
-