'JOLT split flat object into key/value array
I'd like to split simple flat object into array, so each key/value appear as array element. Example:
Input
{ 
   "FIRST_NAME": "John",
   "LAST_NAME": "Doe"
}
Desired output:
[
  {
    "key": "FIRST_NAME",
    "value": "John"
  },
  {
    "key": "LAST_NAME",
    "value": "Doe"
  }
]
Tried various configs but couldn't get anywhere close.
Solution 1:[1]
You can determine each key-value pair through use of $ and @ wildcards respectively within shift transformation spec such as
[
  { 
    "operation": "shift",
    "spec": {
      "*": {
        "$": "[#2].key",
        "@": "[#2].value"
      }
    }
  }
 ]
where
[#2] on the right hand side of the spec represents going up two levels up by traversing one colon(:) and an opening curly bracket({) and grabbing the indices of the arrays for added key and value nodes respectively as using them along with above mentioned wildcards.
the demo on the site http://jolt-demo.appspot.com/ is
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 | 

