Python:两个JSON对象的深度合并

Python:两个JSON对象的深度合并,python,json,Python,Json,我正试图用两代代码从Python中的几个JSON对象构建一个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"

我正试图用两代代码从Python中的几个JSON对象构建一个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}]}]}

有没有一种圆滑的、像蟒蛇一样的方法可以做到这一点?这将以流式方式执行,因为记录进来了,我想将它们合并到主json中。非常感谢您的帮助。

将其保存在数据库中-这将是最有效的方法@madzohan添加I/O通常不是提高效率的方法。@ChrisMartin这是因为“这将以流式方式执行,随着记录的出现,我想将它们合并到主json'@madzohan,我将重新措辞:添加更多I/O通常不是提高效率的方法。