1

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"
} ]

1 Answer 1

3

This worked:

[
  {
    "operation": "remove",
    "spec": {
      "*": {
        "properties": {
          "type": ""
        }
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": "[&1].&",
        "properties": {
          "*": "[&2].&"
        }
      }
    }
  }
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.