demo.py 816 Bytes
# -*- coding: utf-8 -*-

# @Time    : 2021/9/8 16:23
# @Author  : Ljq
# @File    : demo.py
# @Software: PyCharm

"""

"""

ys = {"a":"1","b":{"c":"3"},"dd":[{"e":"5"}]}
gc = {"a":"a","c":"c","e":"e"}

def replaceJsonData(json={},data={}):
    for i in json.keys():
        if i in data.keys() and type(json[i]) != dict and type(json[i]) != list:
            json[i]=data[i]
        elif type(json[i]) == dict:
            json[i] = replaceJsonData(json=json[i],data=data)
        elif type(json[i]) == list:
            for list_child_index in range(len(json[i])):
                if type(json[i][list_child_index]) == dict:
                    json[i][list_child_index] = replaceJsonData(json=json[i][list_child_index], data=data)
    return json


# print(ys["d"])
# a = replaceJsonData(json=ys,data=gc)
# print(a)