com.apama.json
Event JSONPlugin
Convert EPL objects to and from JSON.
Parse JSON to 'any' objects, and 'any' EPL objects to JSON strings.- Since:
- 10.3
Action summary |
any | static fromJSON(string json)
Convert a JSON string representation into an EPL value. |
string | static toJSON(any value)
Convert an EPL value into a JSON string. |
fromJSON
any static fromJSON(string json)
Convert a JSON string representation into an EPL value.- Parameters:
- json - The JSON string form.
- Returns:
- An EPL value of type any. This may contain a string, integer, float, boolean, sequence<any> or dictionary<any, any>.
The returned value never contains any decimal or Apama event values, as these are not represented in JSON.
- Throws:
- If the JSON string cannot be parsed.
toJSON
string static toJSON(any value)
Convert an EPL value into a JSON string.- Parameters:
- value - The value to convert to JSON. Can be a string, integer, float, decimal, boolean, sequence, dictionary or event.
Note that JSON values are not always round-trippable back to EPL as some aspects of EPL types have no representation in JSON: - Decimals are represented in JSON as floats (with loss of precision in many cases).
- Float special values such as float.NAN are represented as strings.
- Dictionaries are converted to JSON objects, provided the key are of type string, number or boolean (other key types will throw an exception).
- Apama events are represented as a JSON object containing the field values but not the event type name.
- Potentially cyclic types (e.g. an event with a field containing a sequence of itself) can be represented as normal, unless the provided value contains an actual cycle in which case an exception will be raised.
- Returns:
- A JSON string
- Throws:
- If an unsupported type is specified.