Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
JSON Explanation | Flask-Smorest and Schemas
Professional Web API with Flask
course content

Зміст курсу

Professional Web API with Flask

Professional Web API with Flask

1. Introduction to the Course
2. Database and Models
3. Flask-Smorest and Schemas
4. Endpoints with Blueprints and MethodView
5. Authentication with JWT
6. Deployment

bookJSON Explanation

So, now we are ready to explore the JSON topic. JSON (JavaScript Object Notation) is a text-based data format. It is language-independent, with many programming languages having built-in support for parsing and generating JSON data. JSON is widely used as a data format for RESTful APIs. It also sends data from the server to the client and vice versa.

  • Lightweight: has a minimal, easy-to-read format;
  • Language-Independent: can be used with most modern programming languages;
  • Human-Readable: structured in a way that's intuitive and easy to comprehend;
  • Easy to Parse: can be easily parsed and generated by machines.

JSON is built on two universal data structures: Objects and Arrays; Objects looks like Python dictionaries when arrays like lists.

A value in JSON can be a string, number, boolean, array, object, or null.

  • String: enclosed in double quotes " ";
  • Number: integer or floating-point;
  • Boolean: true or false;
  • Array: an ordered list of values;
  • Object: an unordered collection of key/value pairs. Similar to Python dictionaries;
  • Null: an empty value, denoted by null;

JSON supports nested objects and arrays, allowing for complex data structures.

But don't forget that JSON is a long string. And if we need to convert Python dict, list or object to the JSON we must stringify it. During the course we will do parsing and serialization.

Parsing (Deserialization) is the process of converting JSON text into a native data structure (as Python List, Dict, or Object). For example, user request is to get the list of all instances of languages from our DB. For that, all information from our API will be sent in and vice versa. Serialization is the process of converting a native data structure into JSON.

Flask usually uses library-based parsing capabilities such as Flask-Smorest and, specifically, Marshmallow library. We will do it in the next chapters.

1. What does JSON stand for?
2. What is the primary use of JSON in web development?
3. In JSON, how can you express a list of multiple objects?
4. What is the correct JSON syntax for an object with a property named "color" and value "blue"?
5. How are strings represented in JSON?
What does JSON stand for?

What does JSON stand for?

Виберіть правильну відповідь

What is the primary use of JSON in web development?

What is the primary use of JSON in web development?

Виберіть правильну відповідь

In JSON, how can you express a list of multiple objects?

In JSON, how can you express a list of multiple objects?

Виберіть правильну відповідь

What is the correct JSON syntax for an object with a property named "color" and value "blue"?

What is the correct JSON syntax for an object with a property named "color" and value "blue"?

Виберіть правильну відповідь

How are strings represented in JSON?

How are strings represented in JSON?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 3
We're sorry to hear that something went wrong. What happened?
some-alt