简体   繁体   English

嵌套 JSON Object 阵列上的颠簸变换

[英]Jolt Transform on Nested JSON Object Array

Would like to flatten JUST the properties nested JSON, but still work for all objects in the input array只想展平嵌套 JSON 的属性,但仍适用于输入数组中的所有对象

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.我编写了每个单独的规范,但是当我将要在一个 object 中使用的规范组合在一起时,它会产生错误的 output - 对象数组真的把它搞砸了。

Thanks!谢谢!

Input:输入:

[
  {
    "type": "Feature",
    "geometry": {
      "type": "MultiLineString",
      "coordinates": [
        [
          [
            -11.11,
            11.11
          ]
        ]
      ]
    },
    "properties": {
      "tester_email": "tester123@123.com",
      "phase_test": "Test 1"
    }
  },
  {
    "type": "Feature22222",
    "geometry": {
      "type": "MultiLineString",
      "coordinates": [
        [
          [
            -11.11,
            11.11
          ]
        ]
      ]
    },
    "properties": {
      "tester_email": "tester123@123.com",
      "phase_test": "Test 1"
    }
  }
]

JOLT Spec:震动规格:

[{
    "operation": "shift",
    "spec": {
      "*": {
        "type": "[&1].type",
        "geometry": "[&1].geometry",
        "properties": "[&1]"
      }
    }
  }
]

Current Output:当前 Output:

[ [ {
  "type" : "Feature",
  "geometry" : {
    "type" : "MultiLineString",
    "coordinates" : [ [ [ -11.11, 11.11 ] ] ]
  }
}, {
  "tester_email" : "tester123@123.com",
  "phase_test" : "Test 1"
} ], [ {
  "type" : "Feature22222",
  "geometry" : {
    "type" : "MultiLineString",
    "coordinates" : [ [ [ -11.11, 11.11 ] ] ]
  }
}, {
  "tester_email" : "tester123@123.com",
  "phase_test" : "Test 1"
} ] ]

Desired Output:所需的 Output:

[ {
"type" : "Feature",
"geometry" : {
  "type" : "MultiLineString",
  "coordinates" : [ [ [ -11.11, 11.11 ] ] ]
},
"tester_email" : "tester123@123.com",
"phase_test" : "Test 1"
},{
"type" : "Feature22222",
"geometry" : {
  "type" : "MultiLineString",
  "coordinates" : [ [ [ -11.11, 11.11 ] ] ]
},
"tester_email" : "tester123@123.com",
"phase_test" : "Test 1"
} ]

This worked:这有效:

[
  {
    "operation": "remove",
    "spec": {
      "*": {
        "properties": {
          "type": ""
        }
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": "[&1].&",
        "properties": {
          "*": "[&2].&"
        }
      }
    }
  }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM