2017-03-09 46 views
1

對於學生項目,我必須提高數據質量。第一步是要求一個API。其次,我們必須編輯json結構。JSON字符串數組使用JOLT對象數組

這是從API響應:

{ 
    "lists": [ 
     [ 
      0, 
      451, 
      "test", 
      "953" 
     ], 
     [ 
      2, 
      1010, 
      "hello", 
      "610" 
     ] 
    ] 
} 

現在使用的顛簸我想有這樣的結果:

{ 
    "lists": [ 
    { 
     "id": 0, 
     "clientId": 451, 
     "name": "test", 
     "custom_value": "953" 
    }, 
    { 
     "id": 2, 
     "clientId": 1010, 
     "name": "hello", 
     "custom_value": "610" 
    } 
    ] 
} 

目前,我可以訪問到的數據值,但我不不知道如何將它與對象分開。

我的「代碼」:

[ 
    { 
    "operation": "shift", 
    "spec": { 
     "lists": { 
     "*": { 
      "*": { 
      "*": { 
       "$0": "lists" 
      } 
      } 
     } 
     } 
    } 
    } 
] 

如果我錯了,我怎樣才能正確地編輯原始陣列的結構?

回答

2

規格

[ 
    { 
    "operation": "shift", 
    "spec": { 
     "lists": { 
     "*": { // lists array 
      "0": "lists[&1].id", 
      "1": "lists[&1].clientId", 
      "2": "lists[&1].name", 
      "3": "lists[&1].custom_value" 
     } 
     } 
    } 
    } 
] 
+0

這麼多的感謝!我花了很多時間,答案很簡單...你讓我的一天 – Alexandre