TOS - replace dynamically a JSON key

Highlighted
Four Stars

TOS - replace dynamically a JSON key

Hello,

 

I'm using Talend Open Studio for Data Integration (no Enterprise licence) and I'm expected to produce a JSON to post it to a REST API.

 

The JSON has something "special" that I'm unable to develop : It has keys that can change :

 

{
       "clientID": "id1",
       "wishes": { 
                  "wishes1" : {
                               "code" : "CND",
                               "name" : "candy"
                  },
                  "wishes2" : {
                               "code" : "CHC",
                               "name" : "chocolate"
                  },
...
"wishesX" : { "code" : "xxx",
"name" : "XXXXXXXXXXXX"
}
} }

 

As you can note, a key is changing : "wishes1", "wishes2", ... , "wishesX". OK, It looks like an array, but it is not ! and it's not me who has decided the API :-( !

I'm unable to do such thing with tWriteJSONField. Can anyone help me ?

 

Thanks in advance,

 

Yves.

 

Tags (2)
Highlighted
Four Stars

Re: TOS - replace dynamically a JSON key

Hello,

any help would be appreciated. Is it possible or not ?

Thanks in advance,

Yves

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