Python json file

Source: Internet
Author: User

{"People":[        {"FirstName": "brett" , " lastname  ": " mclaughlin "}, {"  ": " jason ", " lastname" hunter" }]}     
Introduction to JSON
    • JSON is a lightweight format for data interchange
    • Text format that is completely independent of the programming language to store and represent data
    • The simple and clear hierarchy makes JSON an ideal data exchange language. Easy to read and write, easy to machine parse and generate, and effectively improve network transmission efficiency
    • JSON compared to XML, the data volume is small, transmission speed, the format is compressed
    • The JSON format is syntactically identical to the code that creates JavaScript objects, and because of this similarity, JavaScript programs can easily convert JSON data to Javescript objects
Json method
    • Load
    • Loads
    • Dump
    • Dumps
Example
#coding = Utf-8ImportRequestsImportJsonresponse= Requests.get ("Http://httpbin.org/get")Print(Response.json ()) strtext=json.loads (Response.text)Print(Type (strtext)) forKey,valueinchStrtext.items ():Print(Key,value)Print(strtext["URL"])
{'args': {},'Headers': {'Accept':'*/*','accept-encoding':'gzip, deflateOnnection': 'Close', 'Host': 'httpbin.org', 'User-agent': 'Python-requests/4'}, 'Origin': '111.175.40.89', 'Url': 'Http://httpbin.org/get'}<class 'Dict'>args {}headers {'Accept':'*/*','accept-encoding':'gzip, deflate','Connection': Se', 'Host': 'httpbin.org', 'User-agent': 'python-requests/2.18.4'}Origin 111.175.40.89URL http:httpbin.org/gethttp:Httpbin.org/get

Python json file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.