This article introduces the Python json module description
This article introduces the Python json module description
Introduction
For web developers, json text must be well-known and used. The data returned by API calls of most websites is in json format. If you look at the content contained in the json object, I believe that people familiar with Python will soon be able to map the json data type to the Python data type.
So what is the use of Python's standard module package json? Why should I convert the json format to the corresponding Python format? Why can't I use json data directly? Isn't it of almost the same type and corresponding?
In fact, after looking at the data structure carefully, we can still see that there are still slight differences between the original json format and several data types in Python. Here, we will first list the corresponding formats for mutual conversion between the two:
Python ==> jsondict objectlist, tuple arraystr, unicode stringint, long, float numberTrue trueFalse falseNone nulljson ==> Pythonobject dictarray liststring unicodenumber(int) int, longnumber(real) floattrue Truefalse False
Json commonly used four functions
'Dump'
'Dumps'
'Load'
'Loads'
Specifically, 'dump' and 'load' are used in combination, which is mainly suitable for large data volumes. 'Dumps' and 'loads 'are applicable when strings or data are small. The former is converted to the written file for storage, and the latter is directly loaded into the memory after conversion.
The above is a detailed description of the Python json module. For more information, see other related articles in the first PHP community!