You build the object before encoding it to a JSON string:
import json
data = {}
data['key'] = 'value'
json_data = json.dumps(data)
JSON is a serialization format, textual data representing a structure. It is not, itself, that structure.
More Related Contents:
- Whats wrong with my JSON Object [closed]
- Loading JSON file Using Python Utils Library
- How to draw a histogram from existing bin values
- How to POST JSON data with Python Requests?
- How can I convert JSON to CSV?
- How to convert JSON data into a Python object?
- Converting JSON String to Dictionary Not List
- What are the differences between json and simplejson Python modules?
- recursive iteration through nested json for specific key in python
- How to implement custom indentation when pretty-printing with the JSON module?
- ‘module’ object has no attribute ‘loads’ while parsing JSON using python
- Python Accessing Nested JSON Data [duplicate]
- How to update json file with python
- Opening A large JSON file
- json.loads allows duplicate keys in a dictionary, overwriting the first value
- How to flatten multilevel/nested JSON?
- Python Requests: Post JSON and file in single request
- Convert JSON to XML in Python
- How to append in a json file in Python?
- Unicode values in strings are escaped when dumping to JSON in Python [duplicate]
- Python: Read several json files from a folder
- How to add a key-value to JSON data retrieved from a file?
- JSON ValueError: Expecting property name: line 1 column 2 (char 1)
- How to send requests with JSON in unit tests
- Reading multiple JSON records into a Pandas dataframe
- Python to JSON Serialization fails on Decimal [duplicate]
- Python serializable objects json [duplicate]
- Parsing json and searching through it
- How can I serialize a numpy array while preserving matrix dimensions?
- urllib2 and json