How are these Files structured?
The structure of JSON files is, simply put, an unordered collection of key-value pairs. For Python programmers, this structure is best compared to the Python Dictionary.
The order of the keys “city”, “country” and “population” is not predefined, so a JSON file with a different order than that shown here will still be identical to the file displayed.
The values within a pair can assume different data types. The following types are allowed:
- String, e.g. “city”: “Berlin”.
- Number, e.g. “population”: 3645000
- Object, e.g. another JSON object
- Array, e.g. “districts”: [“Kreuzberg”, “Pankow”, “Reinickendorf”]
- Boolean, e.g. “capital”: True
In JSON no functions can be stored. At the same time, date formats cannot be stored natively. However, this is not a major problem, since you can store dates as strings and then convert them back to a date when reading out the file.
The use of such files is very popular due to their simplicity in structure. The requirements for the data structure are comparatively low and the files are quick and easy to understand for many users.
The widespread use can also be explained by the fact that there are now own parsers for all common programming languages, which make the use of JSON even easier.
As already mentioned, there are some data types that are not supported by default, such as dates. This can be circumvented with the conversion to strings. However, there are different possibilities and libraries, which can be used for this and it was not agreed on any uniform standard.
Which Applications can be realized with JSON?
In addition, it is also suitable for the following use cases:
- Clear data storage: Due to the low data format requirements, flexible data structures can be stored easily.
How to edit JSON files in Python?
From now on you can work with the data in the same way as you are already used to from Python dictionaries.
This is what you should take with you
- It describes a standardized data format for storing data.
- The file format is used for various applications because it is very easy to read and understand.
- The fuzzy number definition is the biggest disadvantage of using this file format.
Thanks to Deepnote for sponsoring this article! Deepnote offers me the possibility to embed Python code easily and quickly on this website and also to host the related notebooks in the cloud.
What is Apache Airflow?
Apache Airflow explained with architecture and application examples.
What is Apache Kafka?
Structure of Apache Kafka explained with possible fields of application.
What is the Star Schema?
Description of the star scheme compared to the snowflake scheme.
What is Apache Spark?
Explanation of Apache Spark with a comparison to Hadoop.
What is a Database Schema?
Explanation of database schemas by example.
What is Presto?
Explanation of Apache Presto compared to Apache Spark.
OLTP: What is Online Transaction Processing?
Explanation of OLTP including its features and differences from OLAP.
Overview of important SQL commands
Common SQL commands explained with the help of examples.
OLAP: What is Online Analytical Processing?
Introduction to Online Analytical Processing with an explanation of the OLAP Cube.
What is a YAML File?
Explanation of YAML files and their use in Python.
Other Articles on the Topic of JSON