Loymax, 2026

Changes for page API methods


From version 3.1
edited by Vera Retyeva
on 2024/03/06 07:57
Change comment: Upload new image "Serialization.png", version 1.1
To version 6.1
edited by Vera Retyeva
on 2024/03/06 08:51
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,26 +1,26 @@
1 1  (% class="lead" %)
2 -Questions related to the work of API methods:
2 +Questions related to API methods:
3 3  
4 -* {{showhide showmessage="Why do some API methods return the $type property?" hidemessage="Why do some API methods return the $type property?"}}|(% style="border-color:white" %)(((
4 +* {{showhide showmessage="Why do some API methods return the $type property in their responses?" hidemessage="Why do some API methods return the $type property in their responses?"}}|(% style="border-color:white" %)(((
5 5  (% class="box infomessage" %)
6 6  (((
7 -**Note:** It is reccomended to read about{{html}}<a href="https://docs.loymax.net/xwiki/bin/view/Main/General_information/Used_technologies/">the technology stack</a>{{/html}} used by the Loymax system.
7 +**Note:** It is reccomended to read about {{html}}<a href="https://docs.loymax.net/xwiki/bin/view/Main/General_information/Used_technologies/">the technology stack</a>{{/html}} used by the Loymax System.
8 8  )))
9 9  
10 10  (((
11 -Objects used in the **.Net** framework are translated from a data structure to a sequence of bytes or a string. In this format it is convenient to transfer and store data.
11 +Objects used in the **.Net** framework are converted from a data structure to a sequence of bytes or a string. This format makes it easier to transfer and store data.
12 12  
13 13  (% class="box" %)
14 14  (((
15 -The process of translating an object state into a stream of bytes in order to store them in PC memory, a database or a file is called **serialization**. The main purpose of serialization is to save the state of an object so that it is possible to restore it if necessary.
16 -The reverse translation of bytes into a data structure is called **deserialization**.
15 +The process of converting an object state into a stream of bytes in order to store them in the PC memory, database or file is called **serialization**. The main purpose of serialization is to save the state of an object so that it can be restored if necessary.
16 +The reverse conversion of bytes into a data structure is called **deserialization**.
17 17  )))
18 18  
19 -The Loymax system uses the **Newtonsoft.Json.JsonSerializer** for serialization/deserialization.
19 +The Loymax System uses the **Newtonsoft.Json.JsonSerializer** for serialization/deserialization.
20 20  )))
21 -)))|(% style="border-color:white" %){{lightbox image="Group 1 (1).png"/}}
21 +)))|(% style="border-color:white" %){{lightbox image="Serialization.png"/}}
22 22  
23 -Let's take the serialization/deserialization process as an example of how the method works for {{html}}<a href="https://docs.loymax.net/xwiki/bin/view/Main/Integration/Ways_to_use_API/API_methods/Methods_of_public_api/Brands/#H41F43E43B44344743543D43843544143F43844143A43043144043543D43443E432">receiving a list of brands</a>{{/html}}
23 +Let's consider the serialization/deserialization process using an example of how the method works {{html}}<a href="https://docs.loymax.net/xwiki/bin/view/Main/Integration/Ways_to_use_API/API_methods/Methods_of_public_api/Brands/#H41F43E43B44344743543D43843544143F43844143A43043144043543D43443E432">to get a list of brands</a>{{/html}}
24 24  
25 25  (((
26 26  
... ... @@ -27,17 +27,17 @@
27 27  )))
28 28  
29 29  |(% style="border-color:white" %)(((
30 -All brands in the System are created using the same template (model), that is, they are inherited from the same data type.
30 +All brands in the System are created using the same template (model), i.e. they are derived from the same data type.
31 31  
32 32  The algorithm for obtaining information about brands through API methods works as follows:
33 33  
34 -1. The client sends a request for a list of brands (##GET: /v1.2/brands###).
35 -1. The server processes the request, generates and sends an SQL-query to the database to get a list of brands.
36 -1. The database, in response to a server request, returns to the server a list of brands that are translated from the byte stream back into a **.Net** object.
37 -1. The server returns to the client a list of brands in JSON format. The **Newtonsoft.Json.JsonSerializer **converts the **.Net** object into JSON format.
34 +1. The customer sends a request for a list of brands (##GET: /v1.2/brands###).
35 +1. The server processes the request, generates and sends an SQL query to the database to get the list of brands.
36 +1. The database responds to the server's request by returning a list of brands that are coverted from a byte stream back to a **.Net** object.
37 +1. The server returns a list of brands to the customer in JSON format. The **Newtonsoft.Json.JsonSerializer **converts the **.Net** object into JSON format.
38 38  )))|(% style="border-color:white" %)[[image:BrandBase.png]]
39 39  
40 -For example, in **.NET** there are types **Brand1 ** and **BrandBase **(**Brand1 ** inherits from **BrandBase**).
40 +For example, **.NET** contains **Brand1 ** and **BrandBase** types (**Brand1 ** is inherited from **BrandBase**).
41 41  
42 42  (% class="box" %)
43 43  (((
... ... @@ -52,16 +52,16 @@
52 52  }##
53 53  )))
54 54  
55 -**Newtonsoft JsonConvert** adds **$type ** property to JSON schema for types during serialization and uses it during deserialization.
55 +**Newtonsoft JsonConvert** adds the **$type ** property to JSON schema for types during serialization and uses it during deserialization.
56 56  
57 -Thus, serializing an instance of the **Brand1 class ** will create a JSON object with the aforementioned **$type** property.
57 +Thus, serialization of the **Brand1** class instance will create a JSON object with the above mentioned **$type** property.
58 58  
59 59  (% class="box infomessage" %)
60 60  (((
61 -**Brand1 **is an object created using the **BrandBase** type. Since the serializer expects to get only an object of type **BrandBase**, and **Brand1 **recognizes it as a separate type that inherits from the common type **BrandBase**, it assigns it the ##$type## property, which specifies the model that the object was created with, to create an object of the source type during deserialization.
61 +**Brand1** is an object created using the **BrandBase** type. Since the serializer expects to get only the object of the **BrandBase** type, and **Brand1** is recognized as a separate type that is inherited from the common **BrandBase** type, it assigns the ##$type## property to it, which specifies the model according to which the object was created, in order to create an object of the original type during deserialization.
62 62  )))
63 63  
64 -In the response to the query for a list of brands, the information about **Brand1 **will look like this
64 +The response to a request to get a list of brands will contain the following information about **Brand1**:
65 65  
66 66  (% class="box" %)
67 67  (((