I have two JSON objects. One is python array which is converted using json,dumps() and other contains records from database and is serialized using json serializer. I want to combine them into a single JSON object.
For eg:
obj1 = ["a1", "a2", "a3"]
obj2 = [{
"pk": "e1",
"model": "AB.abc",
"fields": {
"e_desc": "abcd"
}
},
{
"pk": "e1",
"model": "AB.abc",
"fields": {
"e_desc": "hij"
}
}
]
I want to merge them into single object as below:
finalObj = {
obj1: ["a1", "a2", "a3"],
obj2: [{
"pk": "e1",
"model": "AB.abc",
"fields": {
"e_desc": "abcd"
}
},
{
"pk": "e1",
"model": "AB.abc",
"fields": {
"e_desc": "hij"
}
}
]
}
How can i do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…