Computer >> Computer tutorials >  >> Programming >> Python

How I can dump a Python tuple in JSON format?


JSON stands for Javascript object notation. It is a lightweight, language-independent data interchange format. Python library has json module that provides functions for json encoding and decoding.

The dumps() function converts a Python object to JSON format

>>> T1=(12, "Ravi", "B.Com FY", 78.50)
>>> import json
>>> str1=json.dumps(T1)
>>> str1
'[12, "Ravi", "B.Com FY", 78.5]'