When we need to transform the state of an object to a format that can be stored or sent and restored after this, we can use serialization. The most common approach that is used in development is the serialization of objects to JSON format. An object represented in JSON is a collection of key-value pairs, while a key is represented by a string, and a value can have the following types:
- string
- number
- array
- object
- boolean
The value can also be null. Keys and values are separated by colons, and pairs are separated by commas. In the following example code, JSON contains two pairs that contain values with string types:
{ "first_name": "Igor", "last_name": "Kucherenko" }
The following example code contains the "user" key in accordance with a value of an object type that, in turn, contains an array of...