I started with Jolt, but I can't concatenate the elements of the array to single string,
I have json like this:
{
"partNb": "1234",
"partDescriptions": [
{
"country": "GB",
"language": "en",
"content": "1 tool description in en_GB"
},
{
"country": "GB",
"language": "en",
"content": "2 tool description in en_GB"
}
]
}
and with jolt spec:
[
{
"operation": "shift",
"spec": {
"partNb": "id",
"partDescriptions": {
"*": {
"content": "description"
}
}
}
}
]
For this I have this output:
{
"id" : "1234",
"description" : [ "1 tool description in en_GB", "2 tool description in en_GB" ]
}
but how to get result like this?:
{
"id" : "1234",
"description" : "1 tool description in en_GB , 2 tool description in en_GB"
}
Spec
[
{
"operation": "modify-overwrite-beta",
"spec": {
"description": "=join(', ',@(1,description))"
}
}
]
To get only content fields concatenated into descriptions:
[
{
"operation": "shift",
"spec": {
"partDescriptions": {
"*": {
"content": {
"@": "content"
}
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"description": "=join(', ', @(2,content))"
}
}
]
Output:
{
"content" : [ "1 tool description in en_GB", "2 tool description in en_GB" ],
"description" : "1 tool description in en_GB, 2 tool description in en_GB"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With