A, JSON Introduction
Full name (JavaScript Object Notation), JS objects manifestations
In ajax allowed to build complex formatting the response data to JSON format further responsive to the output.
Two, JSON performance
JSON representation of a single object
{} Represents a single object using
Use key in {}: value is represented in the form of attributes (data)
Key must be used '' in quotes
value
python json str String int,float numebr True,False true,false None null list,tuple array Dec object
JSON represents an array (a set of objects)
Use [] represents an array
Allowing the array comprising a plurality of string or JSON object
var arr = ["str",{object}];
Third, the different files and JSON string conversion
python | js | flask | |
---|---|---|---|
JSON --> string | json.dumps | JSON.stringify | |
string --> JSON | json.loads | JSON.parse | jsonify |
Fourth, the transmission requirements
- The front end transmission json:
request header 'Content-Type', 'application / json' - Get the rear end:
request.get_json [ 'Key']