Introducing serialization

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 phones:

"user": {
            "101": {
"id": 101, "first_name": "Igor",
"last_name": "Kucherenko", "phones": [ +3443432343, +4324233423, +6453454353 ] } }
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.35.122