Extracting JSON values not having the attribute names

0 votes

Hi, I have a JSON input file which does not have any attribute name. Now, how do I extract values from this file?

Input Data:

{
 "A1":{
       "name":"Ad hoc",
       "projectId":0
      },
 "X2":{
       "name":"BBB",
       "projectId":101
        },
 "AB":{
       "name":"CCC",
       "projectId":102
        },
 "recordsCount":3
 }

Output must look like:

 A1, Ad hoc
 X2, BBB
 AB, CCC

Please suggest.

Apr 24, 2018 in Talend by anto.trigg4
• 3,420 points
111 views

1 answer to this question.

0 votes

Sorry, but XPath query can’t read unnamed attributes. To make this file useful you still need to add the surrounding brackets to it and then using JsonPath. In the path, you also need to specify $.*

[
    {
 "A1":{
       "name":"Ad hoc",
       "projectId":0
      },
 "X2":{
       "name":"BBB",
       "projectId":101
        },
 "AB":{
       "name":"CCC",
       "projectId":102
        },
 "recordsCount":3
    }
]

Further, you can extract the values using a tExtractJSONFields component.

But the correct way of extracting the data would be by modifying the data with proper attribute names.

answered Apr 24, 2018 by v.liyyah
• 1,300 points

Related Questions In Talend

0 votes
1 answer

Adding third party libraries into the Talend project

You can add the 3rd party libraries ...READ MORE

answered Apr 9, 2018 in Talend by code.reaper12
• 3,450 points
252 views
0 votes
1 answer

Specifying the number of Rows Processed in Talend

Hi, you can try using tSampleRow component ...READ MORE

answered Apr 14, 2018 in Talend by code.reaper12
• 3,450 points
59 views
0 votes
1 answer

Assigning Context Variable from the database value

I think if you want to link ...READ MORE

answered Apr 19, 2018 in Talend by geek.erkami
• 2,320 points
119 views
0 votes
1 answer
0 votes
1 answer

Performing a JSON Deserialization in Talend

tExtractJSONFields component helps in extracting the desired ...READ MORE

answered Apr 19, 2018 in Talend by code.reaper12
• 3,450 points
236 views
0 votes
1 answer

Looping through all the schemas in Talend

It is really simple to make tOracleInput ...READ MORE

answered Apr 10, 2018 in Talend by code.reaper12
• 3,450 points
61 views
0 votes
1 answer

Parsing JSON in Talend

While working with JSON files, one thing ...READ MORE

answered Apr 2, 2018 in Talend by code.reaper12
• 3,450 points
401 views
0 votes
1 answer