请求Jolt转换帮助:将Map数组转换为数组的数组
Jolt转换:将Map数组转为数组的数组
输入:
{ "items": [{ "a": 1, "b": 1 }, { "a": 2, "b": 2 }] }
期望输出:
{ "items": [ [1, 1], [2, 2] ] }
Jolt转换规则:
[ { "operation": "shift", "spec": { "items": { "*": { "a": "items[&1][0]", "b": "items[&1][1]" } } } } ]
规则说明:
- 用
shift操作重排数据结构 items.*遍历输入里items数组的每一个元素,*指代数组的索引a": "items[&1][0]"把当前元素的a值,放到输出items数组对应索引(&1引用外层的数组索引)的子数组第0位b": "items[&1][1]"同理,将b值放到对应子数组的第1位
内容的提问来源于stack exchange,提问作者Datadev
相关产品推荐
相关产品推荐

