Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JOLT-如何将元素列表转换为JSON_Json_List_Jolt - Fatal编程技术网

JOLT-如何将元素列表转换为JSON

JOLT-如何将元素列表转换为JSON,json,list,jolt,Json,List,Jolt,我有一个元素列表,希望将其传输到JSON对象 [12, 693, 9, 51] 输出结果: [ { "customer_id": 12 }, { "customer_id": 693 }, { "customer_id": 9 }, { "customer_id": 51 } ] 我尝试了以下规范,但得到了null [{ "operat

我有一个元素列表,希望将其传输到JSON对象

[12, 693, 9, 51]
输出结果:

[
  {
    "customer_id": 12
  },
  {
    "customer_id": 693
  },
  {
    "customer_id": 9
  },
  {
    "customer_id": 51
  }
]
我尝试了以下规范,但得到了
null

[{
  "operation": "shift",
  "spec": {
    "*": {
      "customer_id": "[&1]"
    }
  }
}]

这将尝试匹配客户id,而不是在输出中生成它。试试这个:

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

工作很有魅力!谢谢@mattyb!