Python:深度合并两个JSON对象

时间:2014-11-28 18:59:28

标签: python json

我正在尝试用Python中的几个来构建一个单独的JSON对象。两代。

lineage1 = {"name":"rob", "children":[{"name":"henry", "children":[{"name":"johnny", "age":5}]}]}
lineage2 = {"name":"rob", "children":[{"name":"henry", "children":[{"name":"susan", "age":3}]}]}
lineage3 = {"name":"rob", "children":[{"name":"shannon", "children":[{"name":"casey", "age":13}]}]}
lineage4 = {"name":"rob", "children":[{"name":"shannon", "children":[{"name":"alfred", "age":9}]}]}

我想收集(爷爷,(父母,(孩子))。例如。

glin = {"name":"rob","children":[{"name":"henry", "children":[{"name":"johnny", "age":5},{"name":"susan", "age":3}]}, {"name":"shannon", "children":[{"name":"casey", "age":13},{"name":"alfred", "age":9}]}]}

有没有一种光滑,pythonic方式来做到这一点?这将以流式方式执行,因为我想将它们合并到“master”json中。感谢您的帮助。

0 个答案:

没有答案