Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content
Announcements
WEBINAR June 25, 2025: Build on Apache Iceberg with Qlik Open Lakehouse - REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
pthomas
Contributor III
Contributor III

How do I parse children from a hierarchical json file?

I have a table for people.  Those people have friends who have friends.  All people, friend or not, have the same data.  The parent has no other friends but does have a column for that.  This mirrors the data that I am getting.  
 
If I create a json Metedata schema of "friend" to house the columns (id, name, friendOf, someValue), how can I pull this data into a parquet file or other flat file or db?  
 
To the point, how can I parse this with Talend?  How can I use tMap, tExtractJson or other component on an "n" number of levels of the same data?
 
Hopefully, the json isn't too butchered.
 
 
{
"friends": {
    "id": 100,
    "name": "Bob",
"friendOf": null,
"someValue": "58",
    "children": [
{
"id": 101,
"name": "Sue",
"friendOf": "Bob",
"someValue": "123"
},
{
"id": 102,
"name": "Jan",
"friendOf": "Bob",
"someValue": "99",
"children": [
{
"id": 101,
"name": "Ivy",
"friendOf": "Jan",
"someValue": "10"
}
]
},
{
"id": 103,
"name": "Jon",
"friendOf": "Bob",
"someValue": "90"
},
{
"id": 104,
"name": "Ron",
"friendOf": "Bob",
"someValue": "23",
"children": [
{
"id": 105,
"name": "Cal",
"friendOf": "Ron",
"someValue": "777",
"children": [
{
"id": 106,
"name": "Ann",
"friendOf": "Cal",
"someValue": "777"
},
{
"id": 107,
"name": "Leo",
"friendOf": "Cal",
"someValue": "42"
}
]
}
]
}
]
}
}
Labels (5)
1 Solution

Accepted Solutions
5 Replies
Dave_Simo
Creator
Creator

Hello @pthomas 

Use this url to get the correct jsonPath query to parse your json

https://jsonpathfinder.com/

Dave_Simo_0-1749240240320.png

Best Regards

 

pthomas
Contributor III
Contributor III
Author

Thanks for the link.  That's great for working with json files.  But I need Talend to parse a json into a parquet.

BTW, I've used https://jsonformatter.org/ for working with json files but I'll compare that with pathfinder.

Dave_Simo
Creator
Creator

Hello @pthomas 

And which part of the json do you want to parse with the Talend component? The link actually helps you to have the right jsonPath query to use in your tFileInpuJson or tExtractJsonFields.

Best Regards

Dave_Simo
Creator
Creator

Hello @pthomas 

For example

Dave_Simo_1-1749482850969.png

 

Dave_Simo_0-1749482822982.png

 

pthomas
Contributor III
Contributor III
Author

The issue was user!  In my example above if "friends" was in square brackets not curly, that would better simulate my issue.  Getting the "[*]"s right and the "."s is important.  My results were coming back in a comma separated list.  Removing a "." from the json query separated them into individual rows.