I have input with more than 1000 keys in input and there are few objects in my input as well with key value pairs.
I need to transform all the key values to string inside each object as well as outer objects.
When I am using =toString in individual object it is flatting the objects to string as shown in output mentioned below.
Input:
{
"value": 3,
"primary": {
"value": 3
},
"quality": {
"value": 3
}
}
Required Output :
{
"value" : "3",
"primary" : {
"value" : "3"
},
"quality" : {
"value" : "3"
}
}
Jolt tried
[
{
"operation": "modify-overwrite-beta",
"spec": {
"primary": {
"value": "=toString"
},
"*": "=toString"
}
}
]
Output coming from my jolt:
{
"value" : "3",
"primary" : "{value=3}",
"quality" : "{value=3}"
}
2
Answers
You rather can use shift transformations consecutively in this case such as
which will dynamically convert those integers to quoted values, no matter elements you have in the JSON provided the presented model kept for the whole structure.
the demo on the site Jolt Transform Demo Using v0.1.1 is :
You could use String-based approach: