This article covers handling JSON data in Python

In practice, especially when transferring Web data, we often encounter JSON data. It’s not as friendly as common textual data, numeric data, and its resemblance to dictionary-type data in Python has caused a lot of headaches.

In this article, we introduce how to manipulate JSON data using Python and Pandas (a library for Python).

  • Introduction to JSON Data
  • Common JSON data conversion sites
  • Conversion of JSON data to Python data
  • Pandas processes JSON data

Introduction to JSON Data

What is JSON data

First, let’s look at an explanation of JSON from Wikipedia:

JSON (JavaScript Object Notation) is a lightweight data exchange language conceived and designed by Douglas Crockford. It is based on easy-to-read text and is used to transmit data objects consisting of attribute values or sequential values.

JSON data formats are language-independent. Even though it comes from JavaScript, many programming languages today support the generation and parsing of data in JSON format. The file extension is.json.

From the above official introduction, we can conclude three points:

  • JSON is a text (data) language, an ultra-lightweight data interchange format
  • JSON data is easy to read and readable
  • Derived from JavaScript, other languages parse JSON data

Json data type

JSON is actually a subset of JavaScript, with only six data types or any combination of them in the language:

  • Number: the same as the number in JavaScript
  • Boolean: True or false in JavaScript
  • String: string in JavaScript
  • Null: Null in JavaScript
  • Array: JavaScript representation: []
  • Object: the JavaScript{... }representation

Two rules

JSON specifies that the character set must be UTF-8

2, JSON string must be double quotes “” for uniform parsing

Common JSON data conversion sites

Json. cn: www.json.cn/

2, JSON rookie tools: c.runoob.com/front-end/5…

3, soJSON: www.sojson.com/, very full JSON processing…

4. Kjson: www.kjson.com/

5, programming, lion – json inspection tools: www.w3cschool.cn/tools/index…

6, JSONViewer: jsonViewer.stack. hu/, used to check Json format…