How to parse and extract JSON data

Highlighted
Six Stars

How to parse and extract JSON data

Hi all,

 

I have a fairly simple issue that I'm struggling to understand.  I have a straightforward job (shown below) and I'm trying to loop through the JSON output (also below) and eventually use a tMap and push to a DB.  I'm having an issue due to the fact that I don't understand the tExtractJSONFields component thoroughly, nor the difference between the read by options "JsonPath" vs "Xpath".  I've attached the job I have (without the tmap), the JSON structure and the desired output.  I was hoping to have some help on this as well as some clarification on whether or not my thinking is correct on the components I have selected?  Also we're on version 6.2.1.

 

 

{
"paging": {
"pageIndex": 1,
"pageSize": 1000,
"total": 113
},
"measures": [
{
"metric": "METRIC1",
"history": [
{
"date": "DATE1",
"value": "VALUE1"
},
{
"date": "DATE2",
"value": "VALUE2"
},
{
"date": "DATE3",
"value": "VALUE3"
}
]
},
{
"metric": "METRIC2",
"history": [
{
"date": "DATE4",
"value": "VALUE4"
},
{
"date": "DATE5",
"value": "VALUE5"
},
{
"date": "DATE6",
"value": "VALUE6"
}
]
}
]
}

 

Thanks in advance!

 

 


Accepted Solutions
Six Stars

Re: How to parse and extract JSON data

Was able to figure this out actually very simply.  I should have played with Xpath before asking...

 

 

View solution in original post


All Replies
Six Stars

Re: How to parse and extract JSON data

Was able to figure this out actually very simply.  I should have played with Xpath before asking...

 

 

View solution in original post

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 3

Read about some useful Context Variable ideas

Blog