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?

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.

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 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

APIs for Dummies

View this on-demand webinar about APIs....

Watch Now