IBM Streams 4.3.0

Operator JSONToTuple

Primitive operator image not displayed. Problem loading file: ../../image/tk$com.ibm.streamsx.json/op$com.ibm.streamsx.json$JSONToTuple.svg

This operator converts JSON strings into SPL Tuples. The tuple structure is expected to match the JSON schema. A subset of the attributes can be specified as well. Only those attributes that are present in the Tuple schema and JSON input will be converted. All other attributes will be ignored. If an invalid JSON string is found in the input, the operator will fail. This behavior can be overridden by specifying the optional output port or by specifying the "ignoreParsingError" parameter. Attributes from the input stream that match those in the output stream will be automatically copied over. However, if they also exist in the JSON input, their assigned value will be of that specified in the JSON. Null values in JSON arrays are ignored. Null values for all other attributes will result in default initializled output attributes. Limitations: BLOB, MAP and COMPLEX attribute types are not supported in the output tuple schema at this time and will be ignored.

Summary

Ports
This operator has 1 input port and 2 output ports.
Windowing
This operator does not accept any windowing configurations.
Parameters
This operator supports 6 parameters.

Optional: ignoreParsingError, inputAttribute, jsonStringAttribute, jsonStringOutputAttribute, prefixToIgnore, targetAttribute

Metrics
This operator does not report any metrics.

Properties

Implementation
Java

Input Ports

Ports (0)
Properties

Output Ports

Assignments
Java operators do not support output assignments.
Ports (0)

Properties

Ports (1)

Properties

Parameters

This operator supports 6 parameters.

Optional: ignoreParsingError, inputAttribute, jsonStringAttribute, jsonStringOutputAttribute, prefixToIgnore, targetAttribute

ignoreParsingError

Ignore any JSON parsing errors.If the optional output port is enabled, then this parameter is ignored. JSON that cannot be parsed is sent on the optional output port. Default is false where the operator will fail if the JSON cannot be parsed.

Properties
inputAttribute

The input stream attribute (not the name of the attribute) which contains the input JSON string. This attribute must be of rstring or ustring type. Default is the sole input attribute when the schema has one attribute otherwise jsonString. Replaces parameter jsonStringAttribute.

Properties
jsonStringAttribute

Deprecated. Use inputAttribute instead. Name of the input stream attribute which contains the JSON string. This attribute must be of rstring or ustring type. Default is the sole input attribute when the schema has one attribute otherwise jsonString.

Properties
jsonStringOutputAttribute

Name of the output stream attribute which should be populated with the incoming JSON string. This attribute must be of rstring or ustring type. Default is to ignore.

Properties
prefixToIgnore

Specifies a string that, if present, is removed from the start of an attribute name.You can use this method for JSON that contains elements or attributes with SPL or C++ keywords.For example:

stream <rstring __graph> A = JSONToTuple(Input) {
  param ignorePrefix : "__";
}

This example accepts JSON of the following form:

{"graph" : "value"}

Since graph is an SPL keyword, stream<rstring graph> A = JSONToTuple is not valid SPL.

Properties
targetAttribute

Name of the output stream attribute which should be considered as the root of the JSON tuple to be populated. Note that this can only point to a tuple type or collection type attributes (list, set etc). If it points to a list, set etc type attribute, the input JSON is expected to be an array. Default is the output tuple root.

Properties

Libraries

Operator class library
Library Path: ../../impl/lib/com.ibm.streamsx.json.jar, ../../lib/com.ibm.streamsx.json.converters.jar