JSON parsing multiple nested arrays

Highlighted
Four Stars

JSON parsing multiple nested arrays

Hi, I am trying to parse below json, which has multple nested lists (input & output), how do I parse it ?

{
"status":"current",
"entry":[{
"item":{
"name":"Task1",
"identifier":"T00001",
"input":[{
"type":{
"text":"InputTask1-1"
},
"valueString":"Weekly"
},
{
"type":{
"text":"InputTask1-2"
},
"valueString":"Daily"
}
],
"output":[{
"type":{
"text":"OutputTask1-1"
},
"valueString":"Daily"
},
{
"type":{
"text":"OutputTask1-2"
},
"valueString":"Weekly"
}
]
}
},
{
"item":{
"name":"Task2",
"identifier":"T00002",
"input":[{
"type":{
"text":"InputTask2-1"
},
"valueString":"Weekly"
},
{
"type":{
"text":"InputTask2-2"
},
"valueString":"Daily"
}
],
"output":[{
"type":{
"text":"OutputTask2-1"
},
"valueString":"Daily"
},
{
"type":{
"text":"OutputTask2-2"
},
"valueString":"Weekly"
}
]
}
}
]
}

 

Looking for delimited output file like this:

"TaskName"|"TaskId"|"InputName"|"InputValue"|"OutputName"|"OutputValue"
Task1|T00001|InputTask1-1|Weekly|outputDummyText|outputDummyValue
Task1|T00001|InputTask1-2|Daily|outputDummyText|outputDummyValue
Task1|T00001|inputDummyText|inputDummyValue|OutputTask1-1|Daily
Task1|T00001|inputDummyText|inputDummyValue|OutputTask1-2|Weekly
Task2|T00002|InputTask2-1|Weekly|outputDummyText|outputDummyValue
Task2|T00002|InputTask2-2|Daily|outputDummyText|outputDummyValue
Task2|T00002|inputDummyText|inputDummyValue|OutputTask2-1|Daily
Task2|T00002|inputDummyText|inputDummyValue|OutputTask2-2|Weekly

 


Accepted Solutions
Employee

Re: JSON parsing multiple nested arrays

HI,

 

     I have used your input JSON file as reference and I got the following output using the job in below format. You may have to make minor changes based on your specific use case but it will give you a break through.

 

 

image.png

 

image.png

 

Coming to the component details, please refer the screen shot below for each component and schema details.

 

image.png

 

image.png

image.png

 

Hope you got the path to resolve your use case. Please mark the topic as resolved if you are happy with the details. Kudos are also welcome :-)

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

 


All Replies
Four Stars

Re: JSON parsing multiple nested arrays

Screen Shot 2019-04-08 at 5.41.04 PM.png

Employee

Re: JSON parsing multiple nested arrays

HI,

 

     I have used your input JSON file as reference and I got the following output using the job in below format. You may have to make minor changes based on your specific use case but it will give you a break through.

 

 

image.png

 

image.png

 

Coming to the component details, please refer the screen shot below for each component and schema details.

 

image.png

 

image.png

image.png

 

Hope you got the path to resolve your use case. Please mark the topic as resolved if you are happy with the details. Kudos are also welcome :-)

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

 

Six Stars

Re: JSON parsing multiple nested arrays

Hi Nikhil,

 

So I was able to parse a multi-nested JSON but have 2 questions:

 

1. When parsing the data points in the second JSON, I'm getting double quotes and square brackets in the results (screenshot: Result.png). How do I parse these out in tExtractJSONFields? (I can use tReplace as a workaround but was wondering if this could be done in tExtractJSONFields)

 

2. If you check out the JSON.png, you'll see there are two instances of minQty and maxQty, one under filterType: "LOT_SIZE" and another under filterType: "MARKET_LOT_SIZE". Is there a way I can specify in tExtractJSONFields which one to select? For example, if I want to say pick the first one but ignore the second, how do I do that? Or if I want to say parse "LOT_SIZE" and ignore "MARKET_LOT_SIZE", how do I do that?

Employee

Re: JSON parsing multiple nested arrays

@zalibra 

 

  Since your query is for a different use case, I would recommend to create a new post so that we will not dilute the original post context. While creating the post, please also add 5 sample input records, expected JSON output and current output you are getting.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch 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

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog