Closed erelsibm closed 6 years ago
Actually I developed 2 native functions for JSON parsing that I would like to submit for PR: extractFromJSON and queryJSON.
We need to be able to submit multiple JSON Paths, rather than build up the target tuple one field at a time.
Why not call queryJSON multiple times like this:
... output OutStream: x = queryJSON(jsonStr, "/root/a/x"), y = queryJSON(jsonStr, "/root/b/y") ...
Consider the following json: {"name" : "John", "age" : 25 , "partner" : { "name" : "Mary", "age" : 21 } }, "children" : [ { "name" : "Kathy", "age" : 5 }, { "name" : "Peter", "age" : 3 }] };
What should the flat tuplelook like?
@schulz2 we could think about a way to map arrays to a flattened schema, but for now we don't support arrays
@leongor calling this multiple times will result in reparsing the json string which is inefficient - imagine that there's a message with a few hundred fields and we want to extract 20.
@ilanprager in the initial release yes, but I'm going to apply additional 'parseJSON' function that should be called once before 'queryJSON'.
I've added 'parseJSON' function, so now the JSON is parsed only once. Look at the sample here.
Merged - can be closed.
for example consider the following json: {"name" : "John", "age" : 20 , "address" : { "state" : "NY", "country" : "USA" } }";
that should be parsed into the following tuple: stream<rstring name, int32 age, rstring state, rstring country> ParsedS = JSONToTuple(JsonS, JsonPaths) {}