Forum Discussion
You can use the mapValues() method to iterate over the values of the object and perform the transformation. The result of that operation is still an object, so you’ll need to use the jsonPath() function with a path of ‘$*’ to get the values of the object into an array. So, the following should do what you want to create the “custom_fields” property:
jsonPath($.mapValues((value, key) => { value: value, id: parseInt(key.match(/\d+/)[0]) }), "$*")
Related Content
- 4 years ago
- 4 years ago