2017-01-03 103 views
2

剛剛開始接觸顛簸,我試圖改變下列輸入:如何使用Jolt來壓扁n個對象的json數組?

{ 
    "task_name": "Data Full Load", 
    "table": "enterprise", 
    "schema": "dbo", 
    "op": "F", 
    "data": [ 
     { 
      "enterprise_id": "00001" 
     }, 
     { 
      "enterprise_name": "FOO" 
     }, 
     { 
      "note": "" 
     }, 
     { 
      "delete_ind": "N" 
     }, 
     { 
      "create_timestamp": "2004-11-03 22:28:08.180" 
     }, 
     { 
      "modify_timestamp": "2016-05-02 13:02:53.437" 
     }, 
     { 
      "row_timestamp": "0x000000001CDCAAC3" 
     } 
    ] 
} 

進入這個輸出:

{ 
    "enterprise_id": "00001", 
    "enterprise_name": "FOO", 
    "note": "", 
    "delete_ind": "N", 
    "create_timestamp": "2004-11-03 22:28:08.180", 
    "modify_timestamp": "2016-05-02 13:02:53.437", 
    "row_timestamp": "0x000000001CDCAAC3" 
} 

我的數據會有不同的未知元素,所以我不能改變他們的名字。我能夠使用這個規範來提取數據數組,但我不知道如何將元素結合

[ 
    { 
    "operation": "shift", 
    "spec": { "data": "" } 
} 
] 

電流輸出:

[ { 
    "enterprise_id" : "00001" 
}, { 
    "enterprise_name" : "FOO" 
}, { 
    "note" : "" 
}, { 
    "delete_ind" : "N" 
}, { 
    "create_timestamp" : "2004-11-03 22:28:08.180" 
}, { 
    "modify_timestamp" : "2016-05-02 13:02:53.437" 
}, { 
    "row_timestamp" : "0x000000001CDCAAC3" 
} ] 

回答

1

有點扯皮上jolt-demo.appspot.com我想通後出來。對於那些遇到相同挑戰的人來說,這裏是規範:

[ 
    { 
    "operation": "shift", 
    "spec": { 
     "data": { 
     "*": { 
      "*": "&0" 
     } 
     } 
    } 
} 
]