Reputation: 41
Would like to flatten JUST the properties nested JSON, but still work for all objects in the input array
Having trouble putting all three together in one spec (type field, geo field, properties field). I wrote specs to do each one individually, but when I combine the specs to be of use together in one object, it produces the wrong output - the array of objects really messes it up.
Thanks!
Input:
[
{
"type": "Feature",
"geometry": {
"type": "MultiLineString",
"coordinates": [
[
[
-11.11,
11.11
]
]
]
},
"properties": {
"tester_email": "[email protected]",
"phase_test": "Test 1"
}
},
{
"type": "Feature22222",
"geometry": {
"type": "MultiLineString",
"coordinates": [
[
[
-11.11,
11.11
]
]
]
},
"properties": {
"tester_email": "[email protected]",
"phase_test": "Test 1"
}
}
]
JOLT Spec:
[{
"operation": "shift",
"spec": {
"*": {
"type": "[&1].type",
"geometry": "[&1].geometry",
"properties": "[&1]"
}
}
}
]
Current Output:
[ [ {
"type" : "Feature",
"geometry" : {
"type" : "MultiLineString",
"coordinates" : [ [ [ -11.11, 11.11 ] ] ]
}
}, {
"tester_email" : "[email protected]",
"phase_test" : "Test 1"
} ], [ {
"type" : "Feature22222",
"geometry" : {
"type" : "MultiLineString",
"coordinates" : [ [ [ -11.11, 11.11 ] ] ]
}
}, {
"tester_email" : "[email protected]",
"phase_test" : "Test 1"
} ] ]
Desired Output:
[ {
"type" : "Feature",
"geometry" : {
"type" : "MultiLineString",
"coordinates" : [ [ [ -11.11, 11.11 ] ] ]
},
"tester_email" : "[email protected]",
"phase_test" : "Test 1"
},{
"type" : "Feature22222",
"geometry" : {
"type" : "MultiLineString",
"coordinates" : [ [ [ -11.11, 11.11 ] ] ]
},
"tester_email" : "[email protected]",
"phase_test" : "Test 1"
} ]
Upvotes: 1
Views: 1149
Reputation: 41
This worked:
[
{
"operation": "remove",
"spec": {
"*": {
"properties": {
"type": ""
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": "[&1].&",
"properties": {
"*": "[&2].&"
}
}
}
}
]
Upvotes: 3