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 08-16-2018 08:48 PM
I'm to Jolt transformation. I have a simple requirement to transform a json message, were I have to move the contents of the message to a subset without mapping the filed one by one. Input message: { "primary": { "value": 4 }, "quality": { "value": 3 } } Expected Output: { Data:{ "primary": { "value": 4 }, "quality": { "value": 3 } } }.,HI, I am looking to convert a json message using Jolt. it is a simple transformation, were i have to move the entire json message to a subset without mapping field by field
@Matt Burgess
Created on 08-18-2018 06:44 PM - edited 08-17-2019 07:08 PM
Try with below Jolt Spec:
[
{
"operation": "shift",
"spec": {
"*": "Data.&"
}
},
{
"operation": "default",
"spec": {
"Data": {}
}
}
]
Input:
{
"primary": {
"value": 4
},
"quality": {
"value": 3
}
}Output:
{
"Data" : {
"primary" : {
"value" : 4
},
"quality" : {
"value" : 3
}
}
}Another way of doing this is using Replace Text processor by capturing all the content of flowfile and replacement value as
Search Value
(^.*$)
Replacement Value
{ "Data": $1 }
Character Set
UTF-8
Maximum Buffer Size
1 MB
Replacement Strategy
Regex Replace
Evaluation Mode
Entire text
-
If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.
Created on 08-18-2018 06:44 PM - edited 08-17-2019 07:08 PM
Try with below Jolt Spec:
[
{
"operation": "shift",
"spec": {
"*": "Data.&"
}
},
{
"operation": "default",
"spec": {
"Data": {}
}
}
]
Input:
{
"primary": {
"value": 4
},
"quality": {
"value": 3
}
}Output:
{
"Data" : {
"primary" : {
"value" : 4
},
"quality" : {
"value" : 3
}
}
}Another way of doing this is using Replace Text processor by capturing all the content of flowfile and replacement value as
Search Value
(^.*$)
Replacement Value
{ "Data": $1 }
Character Set
UTF-8
Maximum Buffer Size
1 MB
Replacement Strategy
Regex Replace
Evaluation Mode
Entire text
-
If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.
Created 08-18-2018 11:40 PM
Thanks very much @Shu for your solution . I managed to find a way which is almost similar to yours.