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?