Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 06-17-2019 11:23 AM
Hello everyone,
first at all, i am kind of newbie with nifi so feel free to change everywhting you see.
I am ussing JoltTransformJSON. My input JSON is the next one:
{
"ID": "123",
"Text1": "aaa",
"Text2": "aaa",
"Text3": "aaa"
}
And i need the next output:
{
"data": {
"ID": "123",
"Text1": "aaa",
"Text2": "aaa",
"Text3": "aaa"
},
"date": "",
"dataset": "",
"ID": "123"
}
The var date and dataset are attributes from the flow, so there is no problem here, the problem is i need to extract the value of ID, in this case 123 but this is just an example, without deleted the ID inside de field data. My Jolt Specification is the next one:
[{
"operation": "shift",
"spec": {
"*": "data.&"
}
}, {
"operation": "default",
"spec": {
"dataset": "${dataset:toLower()}",
"date": "${date}"
}
}]
and with that i have all EXCEPT the ID field, that i dont know how to do it :(.
Thankss
Created 06-18-2019 12:58 AM
Try with below spec:
[{
"operation": "shift",
"spec": {
"*": "data.&",
"ID": ["ID", "data.ID"]
}
}, {
"operation": "default",
"spec": {
"dataset": "${dataset:toLower()}",
"date": "${date}"
}
}]Output:
{
"ID" : "123",
"data" : {
"ID" : "123",
"Text1" : "aaa",
"Text2" : "aaa",
"Text3" : "aaa"
},
"date" : "${date}",
"dataset" : "${dataset:toLower()}"
}
Created 06-18-2019 12:58 AM
Try with below spec:
[{
"operation": "shift",
"spec": {
"*": "data.&",
"ID": ["ID", "data.ID"]
}
}, {
"operation": "default",
"spec": {
"dataset": "${dataset:toLower()}",
"date": "${date}"
}
}]Output:
{
"ID" : "123",
"data" : {
"ID" : "123",
"Text1" : "aaa",
"Text2" : "aaa",
"Text3" : "aaa"
},
"date" : "${date}",
"dataset" : "${dataset:toLower()}"
}
Created 06-18-2019 03:09 AM
The above was originally posted in the Community Help Track. On Tue Jun 18 03:07 UTC 2019, a member of the HCC moderation staff moved it to the Data Ingestion & Streaming track. The Community Help Track is intended for questions about using the HCC site itself.
Created 06-18-2019 05:59 AM
thanks!! it's works
Created 09-30-2020 12:47 PM
Hi @calonsca!
Please have a look at this spec as well!
[
{
"operation": "shift",
"spec": {
"@": "data",
"ID": "&",
"#${date}": "date",
"#${dataset:toLower()}": "dataset"
}
}
]