Message tree mapping in the JSON domain
When reading a JSON message, the parser builds a message tree from the input bit stream by mapping JSON values to corresponding message tree element types. When serializing a message tree into the output bit stream, tree element types are mapped to JSON value types.
When you use the Graphical Data Mapping editor to transform a JSON message, ensure that the JSON element names that you define by using the Add User Defined function are valid according to the XML element naming rules. JSON allows a wider range of characters than XML, for example a JSON object could include the @ character, however, the Graphical Data Mapping editor only allows element names that are valid in XML or XPath.
JSON bit stream to message tree value mapping
The JSON parser maps JSON values to message tree element types according to the rules in the following table:
JSON value present in bit stream | Parsed as |
---|---|
String | CHARACTER |
JSON Number value presented as:
|
INTEGER |
JSON Number value presented as:
|
FLOAT |
Boolean | BOOLEAN |
Null | NULL |
Message tree to JSON message value mapping
The JSON serializer maps message tree elements to JSON value types according to the rules in the following table:
Message tree Element type | JSON Domain serializes as | |
---|---|---|
JSON type | Format | |
BIT | String | Any number of 0 and 1s |
BLOB | String | Even number of hexadecimal digits |
CHARACTER | String | Char data with JSON string escaping for the
characters that are listed below:
|
DATE | String | The standard ESQL string representation, 'yyyy-mm-dd' |
TIME, GMTTIME | String | The standard ESQL string representation, 'hh:mm:ss.ffffff' |
INTEGER | Number |
|
FLOAT | Number |
|
DECIMAL | Number |
Decimal literals ‘NAN', ‘INF', and so on, are not supported when serializing to JSON. |
BOOLEAN | Boolean | true or false The serializer only serializes Boolean logical tree elements with true or false values; unknown is not supported |
NULL | Null | Null |
ROW | Object | Note: Assigning a ROW directly to a JSON Domain tree does not produce JSON arrays. Produces the following JSON bit stream |
ROW | Array | To produce a JSON array from a ROW type the JSON.Array field would also be set. Produces the following JSON bit stream |