JSON field extraction - simple array and key-value-pairs

Seven Stars

JSON field extraction - simple array and key-value-pairs

Hello everyone

 

I have two JSON questions.

 

Consider below input JSON fragment coming from JSON Input File:

 

"source":{
other JSON fields here ....
"NetworkIdList":["networkdevice_1","networkdevice_2","networkdevice_3"],
"KeyValuePairs":{"Gearbox":"Automatic","Drive":"FrontWheelDrive","BodyStyle":"SUV","Make":"Mitsubishi"},
other JSON fields here ....
}

 

The JSON is in BOLD font.

 

Q(1) simple array extraction (no sub-fields inside array elements)
Q(2) Key-Value-Pair extraction

 

Output desired: for JSON simple array marked as Q(1)

 

NetworkID:
networkdevice_1
networkdevice_2
networkdevice_3

---------------------------------------------

Output Desired: for JSON key-value-pair Q(2)

 

Key              Value:
Gearbox      Automatic
Drive           FrontWheelDrive
BodyStyle   SUV
Make           Mitsubishi

 

Please give me some hints how I can do this inside Talend DI job. 

I am willing to write some Java if it helps me to solve this problem.

 

Thanks in advance

 


Accepted Solutions
Seven Stars

Re: JSON field extraction - simple array and key-value-pairs

tNormalize works for both, thanks!

All Replies
Six Stars

Re: JSON field extraction - simple array and key-value-pairs

Hi Yuri

1.for extracting simple array you can configure the input json as following image and use tnormalize component to split the rows

tfileinputjson-->tnormalize-->tlogrow

 test.jpg.png

Seven Stars

Re: JSON field extraction - simple array and key-value-pairs

Many thanks, I will try this out.

any further guidance re my question (2) key-value-pairs would be most appreciated, I am sure this is a common pattern that occurs in real production applications.


Seven Stars

Re: JSON field extraction - simple array and key-value-pairs

tNormalize works for both, thanks!

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.