How we can convert Python objects into JSON objects?

PythonServer Side ProgrammingProgramming

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]'

raja
Published on 24-Jan-2018 12:33:46
Advertisements