How to merge two json string in Python?

后端 未结 6 2077
醉酒成梦
醉酒成梦 2020-12-08 10:20

I recently started working with Python and I am trying to concatenate one of my JSON String with existing JSON String. I am also working with Zookeeper so I get the existing

6条回答
  •  独厮守ぢ
    2020-12-08 11:10

    You can load both json strings into Python Dictionaries and then combine. This will only work if there are unique keys in each json string.

        import json
    
        a = json.loads(jsonStringA)
        b = json.loads(jsonStringB)
        c = dict(a.items() + b.items())
        # or c =  dict(a, **b)
    

提交回复
热议问题