Is there a way to convert a JSON string to a SPL tuple type without using JSONtoTuple Operator? I saw this documentation: https://developer.ibm.com/streamsdev/docs/introducing-the-json-toolkit/ where they have mentioned a native function for converting tuple to json but not json to tuple.
How do I convert a JSON to Tuple inside a Custom operator?
version 1.4+ of the JSON toolkit includes functions that you can call from a custom. This version must be downloaded from Github, as it is not yet included in the Streams product.
Download the latest version from Github, which is 1.4.4. Build the toolkit:
cd com.ibm.streamsx.jsonand runant.Then you can use the
extractJSONfunction:public T extractFromJSON(rstring jsonString, T value)Pass the JSON string you want to parse, and a mutable tuple that will contain the parsed result as parameters.
For example:
This is based on the ExtractFromJSON sample that you can find in the repo on Github.
Hope this helps.