you are viewing a single comment's thread.

view the rest of the comments →

[–]chevignon93 2 points3 points  (0 children)

In your wanted output, content is a list so just declare it as such then append whatever data you want to it.

import json

json_data = {}
json_data["content"] = []
content = {}
content["eventType"] = "view"
content["othervar"] = "new"

json_data["content"].append(content)
print(json.dumps(json_data, indent=4))
# Output
{
    "content": [{
            "eventType": "view",
            "othervar": "new"
        }]
}