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,440 points
877 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,500 points
3,949 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,500 points
1,848 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,680 points
2,627 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,500 points
2,077 views
0 votes
1 answer

Looping through all the schemas in Talend

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

answered Apr 11, 2018 in Talend by code.reaper12
• 3,500 points
1,882 views
0 votes
1 answer

Parsing JSON in Talend

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

answered Apr 3, 2018 in Talend by code.reaper12
• 3,500 points
4,072 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP