Home > Enterprise >  How to add data in json response?
How to add data in json response?

Time:01-24

I want to add data in my json response from request.post in python.

From this.

{
  "key" : "value"
}

To this ...

{
  "key" : "value"
  "metadata" : { "key1" : "value1", "key2" : "value2"
}

CodePudding user response:

You can add key and value as following

data = {
  "key" : "value"
}
data["metadata"] = { "key1" : "value1", "key2" : "value2"}

CodePudding user response:

You can do it very easily:

data = response.json()
data["metadata"] = yourData
  •  Tags:  
  • Related