Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
We are having a scenario in which we have a JSON with “empty key”. We are unable to parse data for the corresponding key
Sample data as below.
{
"firstName": "John",
"lastName" : "doe",
"age" : 26,
"address" : {
"streetAddress": "naist street",
"city" : "Nara",
"postalCode" : "630-0192"
},
"phone.Numbers": [
{
"type" : "iPhone",
"number": "0123-4567-8888",
"" : "abcd",
},
{
"type" : "home",
"number": "0123-4567-8910",
"" : "pqr",
}
]
}
We are using JSON query for the same to parse in tFileInputJSON.
Please help if anyone came across with this scenario replace battery iPhone
Regards,
davillan
Hi, your json is not valid :
after "abcd" and "pqr" you have comma , you have to delete them.
I can parse it :
I use a tfileinputraw to read the json file as a string (it create an object type) then i use a tconvertType to convert it as a string an then a textractjsonfield with read by JsonPath option:
Loop Jsonpathquery : "$"
Mapping column : json query :
firstname : "firstName"
type: "['phone.Numbers'][*].type"
empty : "['phone.Numbers'][*].['']"
Send me love and kudos
to get all the values :
i read a first time the json with these query :
ex:
LoopJsonpath query : "$"
column : json query:
firstName : "firstName"
phone : "$.['phone.Numbers'][*]."
then i use a tflowtoiterate to stock the value in globalmap and iterate each phone infos of the contact.
and i read again with textractjsonfield the phone string :
ex:
LoopJsonpath query : "$.[*]"
column : json query:
type : "type"
number : "number"
empty : "['']"
and in a tjavarow i add the field i stock before in tflowtoiterate like firstName
ex : if i iterate row3 in my job :
output_row.firstName = ((String)globalMap.get("row3.firstName"));
output_row.type = input_row.type;
output_row.number = input_row.number;
output_row.empty = input_row.empty;