Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One way is to convert the JSON object to a string, add the desired text, and then convert it back to a JSON object. For example:

import json

my_dict = { "key": "value" }
my_str = json.dumps(my_dict)
my_str_with_text = "Additional text: " + my_str
my_object_with_text = json.loads(my_str_with_text)

print(my_object_with_text)

This will output:

{'Additional text': {'key': 'value'}}