Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.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
Arrays 颠簸转换:如何将一些值转移到列表中的每个映射中_Arrays_Json_Dictionary_Transform_Jolt - Fatal编程技术网

Arrays 颠簸转换:如何将一些值转移到列表中的每个映射中

Arrays 颠簸转换:如何将一些值转移到列表中的每个映射中,arrays,json,dictionary,transform,jolt,Arrays,Json,Dictionary,Transform,Jolt,从昨天开始,我一直在进行Jolt转换,无法找到实现以下输出的解决方案。 我想在“记录”列表的每个地图(字典)中插入“年”、“月”、“日” 输入 [{"root": {"body": {"year":2019, "month":8, "day":9, "records":[ {"user":"a", "item":"x", "price":300, "count":1}, {"u

从昨天开始,我一直在进行Jolt转换,无法找到实现以下输出的解决方案。
我想在“记录”列表的每个地图(字典)中插入“年”、“月”、“日”

输入

[{"root":
   {"body":
    {"year":2019,
     "month":8,
     "day":9,
     "records":[
       {"user":"a",
        "item":"x",
        "price":300,
        "count":1},
       {"user":"b",
        "item":"y",
        "price":100,
        "count":3}]
     }
   }
}]
所需输出

[{"user":"a",
  "item":"x",
  "price":300,
  "count":1,
  "year":2019,
  "month":8,
  "day":9},
  {"user":"b",
   "item":"y",
   "price":100,
   "count":3,
   "year":2019,
   "month":8,
   "day":9}
]
我可以将“年”、“月”、“日”的值作为{“记录”:[[2019,8,9]、{map1}、{map2}]等列表插入每个地图的外部,但这不是我想要的。


谢谢你的帮助和建议。并提前向您表示感谢。

这应该可以满足您的要求:

解决方案(在线解释):

输出:

[
  {
    "user": "a",
    "item": "x",
    "price": 300,
    "count": 1,
    "year": 2019,
    "month": 8,
    "day": 9
  },
  {
    "user": "b",
    "item": "y",
    "price": 100,
    "count": 3,
    "year": 2019,
    "month": 8,
    "day": 9
  }
]

这应该满足您的要求:

解决方案(在线解释):

输出:

[
  {
    "user": "a",
    "item": "x",
    "price": 300,
    "count": 1,
    "year": 2019,
    "month": 8,
    "day": 9
  },
  {
    "user": "b",
    "item": "y",
    "price": 100,
    "count": 3,
    "year": 2019,
    "month": 8,
    "day": 9
  }
]