How we can convert Python objects into JSON objects?



Suppose we have a list object a = [1,2,3]. We convert a python object into a JSON object by importing json module and using the method json.dumps() as follows.

>>> a = [1,2,3]
>>> import json
>>> json.dumps(a)
'[1, 2, 3]'

The JSON object we got is '[1, 2, 3]'


Advertisements