Hello All,
I have a JSON file from which i need to read data. The file is not in any particular format and may have about 45,000 lines of data.
To read document file the the only function i can find is readtextfromfile but problem with this function (in my scenario) is its converting JSON into a single text string
and because of which i am not able to use index function on it. I want data in any format.
We had a different input method before, Instead of JSON file we received data from DB so i was getting data in List of Variant instead of text.
Discussion posts and replies are publicly visible
I think this is what you're looking for:
Assuming cons!SBX_DOCUMENT_JSON_EXAMPLE is a constant of type document, and the content of that document is:
{ "age":100, "name":"xyz.com", "messages":["msg 1","msg 2","msg 3"]}
THEN
index( {a!fromJson( {fn!readtextfromfile(cons!SBX_DOCUMENT_JSON_EXAMPLE, true())} )}, "messages" )
List of Text String: 3 items "msg 1" "msg 2" "msg 3"
AND
index( {a!fromJson( {fn!readtextfromfile(cons!SBX_DOCUMENT_JSON_EXAMPLE, true())} )}, "age" )
100
Found an answer from this link. Thanks for quick reply everyone.
NOTE: I had null data in my JSON, i used substitute to replace null with "".
Thanks for this one it helps to know that using null inside will result in error before hand.