Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi, I am using Talend cloud DI 7.3. I am a newbie in using component tWriteJSONField to configure JSON tree.
I have a table row like this:
first_name, last_name, role, catogory1, category2
Joe, Dee, undergrad, 49614,49715
How can I get a JSON data output string like below?
{
"data"
: {
"type"
:"registration_sets"
,
"attributes"
: {
"registrations"
: [{
"rule_set"
:"user_rule_set"
,
"first_name"
:"Joe"
,
"last_name"
:"Dee"
,
"category_labels"
: [
"49614"
,
"
49715
"
]
},
{
"rule_set"
:"he_learner"
,
"role"
:"undergrad"
}
]
}
}
}
your help will be very appreciated.
The best way to do this will depend upon your data. This looks like a small structure where you are limited to these input columns....
first_name, last_name, role, category1, category2
....with 1 row of data. Do you need a complete and separate file for every row in the data. Is the input data limited to the columns you have shown?
I have tDBInput query getting a dataset with columns: first_name, last_name, role, category1, category2. The each row of dataset will be iterated generating a separate JSON string to post data using tRestClient. In the JSON body, rule_set is fixed value.
The JSON structure will be like this:
{
"data": {
"type": "registration_sets",
"attributes": {
"registrations": [
{
"rule_set": "user_rule_set",
"first_name": "Test10",
"last_name": "Test10",
"category_labels": [
"49614",
"49575"
]
},
{
"rule_set": "he_learner",
"role": "undergrad"
}
]
}
}
}
How can I use tWriteJSONField or java jackson class to generate the file?
Thank you.
I made it working using jackson classes.
Thank you for your help.