Python JSON module

Source: Internet
Author: User

1 Import JSON2 3 # Json.dumps is used to encode a Python object into a JSON string. 4Print (Json.dumps (['Foo', {'Bar': ('Baz', None,1.0,2)}]))5Print (Type (Json.dumps (['Foo', {'Bar': ('Baz', None,1.0,2)}])))6 7 # json.loads is used to decode JSON data. The function returns the data type of the Python field. 8Print (Json.loads ('{"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}'))9Print (Type (json.loads ('{"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}')))
1["Foo", {"Bar": ["Baz", NULL, 1.0, 2]}]2<class 'Str'>3{'a': 1,'b': 2,'C': 3,'D': 4,'e': 5}4<class 'Dict'>

Python JSON module

Related Article

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.