Read JSON formatted string in Python
You should use the json
Python package. To have a JSON, you could simply do import json
and json.dumps(message)
.
Use a Json package in python
import jsondata = json.loads(your_var)
In data variable you get a json format data
hope this will help you
Will something like this work for you?
import json# assume this is the JSON you receivetext = json.dumps(dict(name='Jack', age='24'))# show the text to be convertedprint(text)# outputs: {"name": "Jack", "age": "24"}# load a string and convert to Python object# see `json` module more for detailsobj = json.loads(text)