introduction and use of json

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

  1. JSON representation of a single object

    1. {} Represents a single object using

    2. Use key in {}: value is represented in the form of attributes (data)

    3. Key must be used '' in quotes

    4. value

      python json
      str String
      int,float numebr
      True,False true,false
      None null
      list,tuple array
      Dec object
  2. JSON represents an array (a set of objects)

    1. Use [] represents an array

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

Guess you like

Origin www.cnblogs.com/yangjunh/p/json.html