Create JSON structure with multiple values

Two Stars

Create JSON structure with multiple values

Hi, I need help with creating JSON structure. I need to get it look like this:

{
"dps":[ { "x":1485801000000, "y":[ 37.22, 37.37, 36.64, 36.82 ] }, { "x":1485714600000, "y":[ 37.74, 37.84, 37.33, 37.42 ] }, { "x":1485455400000, "y":[ 38.0, 38.45, 37.81, 37.98 ] }
]
}

 It means that there is one loop called "dps" containing array of data. Each part of this loop cantains two elements x and y. X has single value, but Y has multiple values (array).

 

This is how my input data looks like:

 

123456789|91.2650|91.7500|89.6600|89.7900
123456799|89.5000|90.4600|87.0800|87.1800
123456788|90.6100|94.0000|90.4000|93.7800
123456777|94.9400|95.1390|88.5100|89.4700

 

My x value is in the first column of each row. Y values are stored in other four columns. I tried almost everything with tWriteJsonField but no success came out.

 

Does anyone have an idea how to deal with it?

Tags (2)
Moderator

Re: Create JSON structure with multiple values

Hello,

Could you please take a look at this webpage:  

https://help.talend.com/reader/KxVIhxtXBBFymmkkWJ~O4Q/50PMKM8mz4A5fAL~FQcLHw?section=twritejsonfield...?

Here is a related topic:https://community.talend.com/t5/Design-and-Development/Create-array-inside-JSON/m-p/54119

Best regards

Sabrina

 

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

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.