IBMStreams / streamsx.json

Toolkit for working with JSON in SPL applications.
http://ibmstreams.github.io/streamsx.json/
Other
3 stars 19 forks source link

TupleToJSon should NOT generate output if the list is empty #44

Closed chanskw closed 4 years ago

chanskw commented 8 years ago

Assuming a tuple has the following type:

type DataType = tuple<rstring a,list<rstring> b,list<rstring> c>;

If a tuple of this data type contains the following: Data1: data={a="A", b=[], c=[]}

In this particular case, both b and c are empty lists.

Currently, the TupleToJson operator generates the following: {"a":"A","b":[],"c":[]}

The user would like to see both "b" and "c" to be suppressed from the output.

m-kotowski commented 8 years ago

The requirement is that an JSON element is suppressed if the corresponding tuple attribute is marked as optional and has a value that is not present. Since SPL does not support a "null" value, SPL values can marked as "not present" in different ways.

  1. The SPL attribute has a list or set type. If the list or set is empty, the optional value is not present. If the list has a value, the optional value is present.
  2. There is an additional SPL attribute in the SPL schema, which indicates whether the optional value is present or not present. For example, boolean or bitmask values.

It would be great, if the solution can be used for any of these ways. For example, an expression that is specified for SPL attributes indicating whether the SPL value is present or not present. In addition, it might be useful that the expression can be specified for any SPL attribute, even for sub values, for example, for C in tuple<rstring A, list<tuple<rstring C, rstring D, boolean isPresent_C>> B>.

rnostream commented 4 years ago

Same as #43