'JSON to JSON changing array to one long string using JOLT

Lets say my json is:

{
 "rating": {
  "primary": {
   "value": ["a","B",1]
  }
 }
}

What I want to achieve is:

{
 "values": "a, B, 1"
}

I'm using jolt json to json code.



Solution 1:[1]

It is not possible with stock transformations of Jolt. You need to write your custom transformation. Check the documentation section on how to write your own transformations.

Solution 2:[2]

you can try the following spec

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "value": "=concat(@(2,rating.primary.value[0]),',',@(2,rating.primary.value[1]),',',@(2,rating.primary.value[2]))"
    }
  },
  {
    "operation": "remove",
    "spec": {
      "rating": ""
    }
  }

]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Manohar
Solution 2 M. Adeel Khalid