Data serialization method, deserialization method, device, equipment and storage medium

By using configuration files and constructors in the Windows kernel to parse tree structure nodes, secure and efficient data serialization and deserialization are achieved, solving the problem of the lack of data serialization support libraries in the Windows kernel and improving the security and efficiency of data transmission.

CN116340993BActive Publication Date: 2026-11-24戎码科技(北京)有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310144257.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-17
Publication Date
2026-11-24
Estimated Expiration
2043-02-17

AI Technical Summary

Technical Problem

In existing technologies, the Windows kernel lacks a data serialization support library, which makes it impossible to guarantee data security. Serialization needs to be performed by calling third-party support libraries at the application layer, which reduces data security.

Method used

The Windows kernel provides data serialization and deserialization methods. It parses nodes in the tree structure through configuration files and constructors, and uses depth-first traversal and breadth-first traversal algorithms to achieve secure and efficient data serialization and deserialization.

Benefits of technology

Performing data serialization and deserialization directly within the Windows kernel improves data security, avoids the security risks associated with calling third-party libraries through the application layer, and enhances the security and efficiency of data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116340993B_ABST
    Figure CN116340993B_ABST
Patent Text Reader

Abstract

This application provides a data serialization method, deserialization method, apparatus, device, and storage medium. The method can run in the Windows kernel of an electronic device. The method includes: obtaining a tree structure corresponding to data to be serialized, where nodes in the tree structure represent field information contained in the data to be serialized; traversing the tree structure and parsing each node in the tree structure to obtain a parsing result; wherein the parsing result is the result obtained after serializing the data to be serialized. This application provides a method for data serialization within the Windows kernel, thereby enabling data serialization within the Windows kernel and improving data security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more specifically, to a data serialization method, deserialization method, apparatus, device, and storage medium. Background Technology

[0002] Currently, to facilitate data transmission, existing third-party libraries provide support for data serialization, but there are no support libraries for data serialization within the Windows kernel. When the kernel needs to perform serialization, the application layer software must call a third-party support library. The application layer then serializes the data that the Windows kernel needs to serialize before passing the serialized data to the Windows kernel. This method of serialization through the application layer compromises data security. Summary of the Invention

[0003] The purpose of this application is to provide a data serialization method, deserialization method, apparatus, device, and storage medium, so as to provide a way to perform data serialization and deserialization processing in the Windows kernel and improve data security.

[0004] In a first aspect, embodiments of this application provide a data serialization method, which can run in the Windows kernel of an electronic device, including:

[0005] Obtain the tree structure corresponding to the data to be serialized, where the nodes in the tree structure are used to represent the field information contained in the data to be serialized;

[0006] Traverse the tree structure and parse each node in the tree structure to obtain the parsing result; where the parsing result is the result obtained after serializing the data to be serialized.

[0007] This application provides a method for data serialization within the Windows kernel, thereby enabling data serialization within the Windows kernel without requiring application-layer calls to third-party support libraries, thus improving data security.

[0008] In any embodiment, parsing each node in the tree structure includes:

[0009] Obtain the configuration file and constructor; the configuration file is used to identify the data type of the node; the constructor is used to parse nodes whose data type has sub-data regions.

[0010] The leaf nodes in the tree structure are parsed according to the configuration file; the parent nodes in the tree structure are parsed according to the configuration file and the constructor.

[0011] This application embodiment improves data security by using configuration files and constructors to parse each node in the tree structure, thereby completing the serialization of the data to be serialized in the Windows kernel.

[0012] In any embodiment, parsing the leaf nodes in the tree structure according to the configuration file includes:

[0013] The data type of the node in the tree structure is determined based on the configuration file;

[0014] If the data type represents the node as the smallest unit of data, then the smallest unit of data is written to the cache.

[0015] The parent nodes in the tree structure are parsed according to the configuration file and the constructor, including:

[0016] If the data type representation node has sub-data regions, the constructor is used to continue parsing the data regions until the smallest unit of data is obtained, and the smallest unit of data is written to the cache.

[0017] This application embodiment completes the serialization of data by parsing the nodes in the tree structure into the smallest unit of data, thus facilitating data transmission.

[0018] In any embodiment, the tree structure can be efficiently and completely parsed by using a depth-first traversal algorithm.

[0019] Secondly, embodiments of this application provide a data deserialization method, which can run in the Windows kernel of an electronic device, including:

[0020] Obtain the data to be deserialized and the corresponding configuration file;

[0021] The data to be deserialized is parsed according to the configuration file, and a tree structure corresponding to the data to be deserialized is generated.

[0022] Deserialized data is generated based on a tree structure.

[0023] The data deserialization method provided in this application embodiment can be implemented in the Windows kernel, thereby improving data security.

[0024] In any embodiment, parsing the data to be deserialized according to the configuration file includes:

[0025] The configuration file contains multiple data regions of the data to be deserialized.

[0026] If the data area has sub-data areas, the data area is written into the processing queue, and the data area in the processing queue is parsed again using the configuration file until the smallest unit of data is obtained.

[0027] If the data area is the smallest unit of data, then the data area is inserted into the tree structure.

[0028] This application embodiment determines the type of the data region through a configuration file, and parses the data to be deserialized to the smallest unit according to the data region's data type, thus completing the deserialization process of the data to be deserialized. Since the deserialization operation is implemented in the Windows kernel, data security is improved.

[0029] In any embodiment, multiple data regions contained in the data to be deserialized are obtained according to the configuration file, including:

[0030] The breadth-first search algorithm is used to obtain multiple data regions contained in the data to be deserialized based on the configuration file.

[0031] This application embodiment uses a breadth-first search algorithm to parse the data to be deserialized, preventing stack overflow during data serialization.

[0032] Thirdly, embodiments of this application provide a data serialization apparatus that runs in the Windows kernel of an electronic device, comprising:

[0033] The acquisition module is used to obtain the tree structure corresponding to the data to be serialized. The leaf nodes in the tree structure are used to represent the field information contained in the data to be serialized.

[0034] The node parsing module is used to traverse the tree structure and parse each node in the tree structure to obtain the parsing result; the parsing result is the result obtained after serializing the data to be serialized.

[0035] Fourthly, embodiments of this application provide a data deserialization apparatus that runs in the Windows kernel of an electronic device, comprising:

[0036] The acquisition module is used to acquire the data to be deserialized and the corresponding configuration file;

[0037] The data parsing module is used to parse the data to be deserialized according to the configuration file and generate the tree structure corresponding to the data to be deserialized.

[0038] The generation module is used to generate deserialized data based on a tree structure.

[0039] Fifthly, embodiments of this application provide an electronic device, including: a processor, a memory, and a bus, wherein,

[0040] The processor and the memory communicate with each other via the bus;

[0041] The memory stores program instructions that can be executed by the processor, and the processor can execute the method of the first aspect or the second aspect by calling the program instructions.

[0042] Sixthly, embodiments of this application provide a non-transitory computer-readable storage medium, comprising:

[0043] The non-transitory computer-readable storage medium stores computer instructions that cause the computer to perform the method of the first aspect or the second aspect.

[0044] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing embodiments of this application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0045] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0046] Figure 1 This is a schematic diagram of a data serialization method provided in an embodiment of this application;

[0047] Figure 2 A schematic diagram of a tree structure provided in an embodiment of this application;

[0048] Figure 3 This is a schematic diagram of another serialization operation provided in an embodiment of this application;

[0049] Figure 4 This is a schematic diagram of a data deserialization method provided in an embodiment of this application;

[0050] Figure 5 This is a schematic diagram of the data to be deserialized provided in an embodiment of this application;

[0051] Figure 6 This is a schematic diagram of another deserialization operation provided in an embodiment of this application;

[0052] Figure 7 This is a schematic diagram of a data serialization device structure provided in an embodiment of this application;

[0053] Figure 8 A schematic diagram of a data deserialization device provided in an embodiment of this application;

[0054] Figure 9 This is a schematic diagram of the physical structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0055] The embodiments of the technical solution of this application will now be described in detail with reference to the accompanying drawings. These embodiments are only used to more clearly illustrate the technical solution of this application and are therefore merely examples, and should not be used to limit the scope of protection of this application.

[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.

[0057] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.

[0058] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0059] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.

[0060] In the description of the embodiments of this application, the term "multiple" refers to two or more (including two), similarly, "multiple sets" refers to two or more (including two sets), and "multiple pieces" refers to two or more (including two pieces).

[0061] In the description of the embodiments of this application, unless otherwise expressly specified and limited, technical terms such as "installation," "connection," "joining," and "fixing" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. For those skilled in the art, the specific meaning of the above terms in the embodiments of this application can be understood according to the specific circumstances.

[0062] To facilitate understanding of the embodiments of this application, the relevant concepts involved in the embodiments of this application are explained:

[0063] Protocol Buffer (PBR) is Google's internal mixed-language data standard. It serializes structured data, providing a language-independent, platform-independent, and scalable serialized structured data format for applications such as communication protocols and data storage.

[0064] Windows kernel development: In Windows, applications are divided into the application layer (ring 3) and the kernel layer (ring 0). Kernel programs run at Ring 0, therefore they have higher privileges than ordinary Ring 3 programs running at the application layer. Thus, kernel programming often brings more powerful functionality to traditional software, enabling technological leaps.

[0065] Serialization: The process of converting an object into a sequence of bytes. Its main purpose is to ensure the integrity and transmissibility of objects when transmitting and saving them. Objects are converted into an ordered stream of bytes for transmission over a network or storage in a local file.

[0066] Deserialization: The process of restoring a byte sequence into an object. Its main function is to reconstruct the object based on the object state and description information stored in the byte stream.

[0067] Depth-First Traversal (DFT) assumes a graph G initially containing all unvisited vertices. Choosing any vertex v as the starting point (source), DFT is defined as follows: First, visit the starting point v and mark it as visited. Then, sequentially search each adjacent vertex w of v. If w has not been visited, continue DFT from w as the new starting point until all vertices in the graph that are path-connected to the source vertex v (i.e., reachable vertices from the source) have been visited. If there are still unvisited vertices, select another unvisited vertex as the new source and repeat the process until all vertices in the graph have been visited.

[0068] Breadth-first search (BFS) starts from a node and traverses the nodes from top to bottom according to the hierarchy. Within the same level, it traverses the nodes from left to right: first visiting the root node, then visiting the vertices that are 1 unit away from the root node. Assuming there are 3 nodes adjacent to the root node, depth-first search will visit these 3 nodes after visiting the root node. After visiting the nodes that are 1 unit away from the root node, they are removed and the same process is repeated.

[0069] Through extensive research, the inventors of this application discovered that there is currently no ProtoBuffer parsing solution in drivers. The alternative is to use communication between the Windows kernel and the application layer. The application layer software calls Google's support library to parse or construct the data before passing it into the Windows kernel for use. However, since the application layer's security is lower than that of the Windows kernel, passing data from the Windows kernel to the application layer reduces data security.

[0070] To address the aforementioned technical problems, this application provides a data serialization method, a deserialization method, an apparatus, a device, and a storage medium. It is understood that the data serialization and deserialization methods provided in this application can run within the Windows kernel of an electronic device. The electronic device can be a smartphone, tablet computer, computer, personal digital assistant (PDA), etc.

[0071] Figure 1 This is a schematic diagram of a data serialization method provided in an embodiment of this application, such as... Figure 1 As shown, the method includes:

[0072] Step 101: Obtain the tree structure corresponding to the data to be serialized. The nodes in the tree structure are used to represent the field information contained in the data to be serialized.

[0073] Step 102: Traverse the tree structure and parse each node in the tree structure to obtain the parsing result; where the parsing result is the result obtained after serializing the data to be serialized.

[0074] In step 101, the data to be serialized can be written in C language, or in other programming languages ​​such as C++. This embodiment does not specifically limit this. After obtaining the data to be serialized, if a corresponding tree structure already exists, it can be obtained directly. If no tree structure exists, it can be constructed based on the data to be serialized, or it can be generated after deserializing the data. This embodiment does not specifically limit the method of obtaining the tree structure. Figure 2This is a schematic diagram of a tree structure provided in an embodiment of this application. The tree structure includes multiple nodes, including leaf nodes, parent nodes, and a root node. The root node has no practical meaning. The leaf nodes and parent nodes represent the field information contained in the data to be serialized, such as the data type of the field (varint, string, etc.) and the field name. The leaf node represents the smallest unit of the data to be serialized, and the parent node represents the data region with sub-data areas within the data to be serialized. It should be noted that the above... Figure 2 The example shown is just one example; the specific tree structure can be generated based on the actual data to be serialized.

[0075] In step 102, when serializing the data to be serialized, the tree structure can be traversed to parse each node and obtain the parsing result. For example, each node can be converted into a byte sequence conforming to the Peorobuffer format.

[0076] This application provides a method for data serialization within the Windows kernel, thereby enabling data serialization within the Windows kernel without requiring application-layer calls to third-party support libraries, thus improving data security.

[0077] Based on the above embodiments, each node in the tree structure can be parsed in the following way:

[0078] Obtain the configuration file and constructor; wherein, the configuration file is used to identify the data type corresponding to the node; the constructor is used to parse the node whose data type has sub-data regions;

[0079] The leaf nodes in the tree structure are parsed according to the configuration file; the parent nodes in the tree structure are parsed according to the configuration file and the constructor.

[0080] In the actual implementation process, the configuration file is a pre-generated file used to identify the data types of the fields corresponding to each node in the tree structure. For example, it can be a JSON file, which may contain the following content:

[0081]

[0082]

[0083] In the configuration file above, the value following each field indicates whether the node corresponding to that field is the smallest unit. "0" indicates that the corresponding node is the smallest unit, and "1" indicates that the corresponding node is not the smallest unit, i.e., it is a data region with sub-data regions. In addition, the data region of the smallest unit is located at the leaf node in the tree structure, and the data region with sub-data regions is located at the parent node in the tree structure.

[0084] Figure 3 Another serialization operation diagram provided for an embodiment of this application, such as... Figure 3 The constructor shown is used to parse nodes with sub-data regions and split them. For example, when traversing to the root node, there are four nodes after the root node. Parsing these four nodes yields a varint node, a string node, a shujukuai1 node, and a shujukuai2 node. After obtaining these four nodes, the data type of the four nodes is queried using the configuration file. The varint and string nodes are the smallest units, and are written to the buffer. The shujukuai1 and shujukuai2 nodes are nodes with sub-data regions, and the constructor is used to continue parsing them. The shujukuai1 node can be parsed to obtain a varint node, a string node, and a shujukuai3 node; the shujukuai2 node can be parsed to obtain a varint node. By querying the configuration file, it can be seen that the varint and string nodes are leaf nodes, and the shujukuai3 node is a node with sub-data regions. The varint and string nodes can be added to the buffer, and the constructor can be used to parse the shujukuai3 node to obtain the varint node. By checking the configuration file, we know that the varint node is the smallest unit of node; therefore, the data corresponding to the varint node can be written to the buffer. After parsing all nodes in the tree structure to the smallest unit and writing them to the buffer, the serialization operation of the data to be serialized is completed.

[0085] This application embodiment improves data security by using configuration files and constructors to parse nodes in a tree structure and serialize the data to be serialized in the Windows kernel.

[0086] Based on the above embodiments, when traversing the tree structure, a depth-first traversal algorithm can be used. The depth-first traversal algorithm can improve the efficiency of parsing the tree structure and reduce the possibility of missing nodes.

[0087] Figure 4 This is a schematic diagram of a data deserialization method provided in an embodiment of this application, such as... Figure 4 As shown, the method includes:

[0088] Step 401: Obtain the data to be deserialized and the corresponding configuration file;

[0089] Step 402: Parse the data to be deserialized according to the configuration file to generate a tree structure corresponding to the data to be deserialized;

[0090] Step 403: Generate deserialized data based on the tree structure.

[0091] In step 401, the data to be deserialized can be serialized data obtained by serializing the original data. The serialized data is then deserialized to obtain the original data. For example, when a server sends some original data to a terminal, the server can serialize the original data to obtain a byte sequence and send the byte sequence to the terminal. After receiving the byte sequence, the terminal obtains the original data by deserializing the byte sequence. Figure 5 This is a schematic diagram of the data to be deserialized provided in an embodiment of this application. The data to be deserialized can be protobuffer data.

[0092] The configuration file contains the data types of the fields in the data to be deserialized. The data type indicates whether the field is a single unit of data or a data range with sub-data areas. For example, it can be a JSON file, which may contain the following:

[0093]

[0094]

[0095] In the above configuration file, the value following each field is used to indicate whether the node corresponding to that field is the smallest unit. "0" indicates that the corresponding node is the smallest unit, and "1" indicates that the corresponding node is not the smallest unit, that is, a data area with sub-data areas.

[0096] In step 402, the data region containing sub-data areas in the data to be deserialized is also of data type string, the same as the smallest unit of string data. Therefore, to distinguish between the smallest unit of string data and the data region containing sub-data areas, identification can be performed through a configuration file. The smallest unit of data in the data to be deserialized is parsed out, and the parsed smallest unit of data is inserted into the tree structure to obtain the final tree structure, such as... Figure 2 As shown.

[0097] In step 403, after obtaining the tree structure, the tree structure can be converted into deserialized data. It is understood that the process of converting the tree structure into deserialized data is similar to the serialization process described above, and will not be repeated here in this embodiment.

[0098] The data deserialization method provided in this application embodiment can be implemented in the Windows kernel, thereby improving data security.

[0099] Based on the above embodiments, the data to be deserialized can be parsed using the following method:

[0100] The multiple data regions contained in the data to be deserialized are obtained according to the configuration file;

[0101] If the data area is a data area with sub-data areas, then the data area is written into the processing queue, and the data area is parsed again using the configuration file until the smallest unit of data is obtained.

[0102] In the specific implementation process Figure 6 This is another deserialization operation diagram provided in the embodiments of this application, such as... Figure 6 As shown, the main data block of the data to be deserialized can be written into the parsing queue first, such as... Figure 5 The outermost data block is formed by parsing the main data block in the parsing queue according to the configuration file. The parsing function can be a breadth-first search algorithm to obtain the varint numeric data area, the string string data area, data area 1 containing sub-data areas, and data area 2 containing sub-data areas. Since the varint numeric data area and the string string data area are the smallest units of data, they are inserted into the tree structure, generating two nodes in the tree structure to store data area 1 and data area 2 containing sub-data areas, respectively. Since data area 1 and data area 2 containing sub-data areas are not the smallest units of data, the main data blocks corresponding to data area 1 and data area 2 containing sub-data areas are written into the processing queue. When the processing queue contains main data blocks to be parsed, the configuration file can be used to continue parsing the main data blocks in the processing queue until all the data to be deserialized is written into the tree structure, obtaining the final tree structure, such as... Figure 2 As shown. Understandably, the obtained tree structure can be stored in memory.

[0103] This application embodiment determines the type of the data region through a configuration file, and parses the data to be deserialized to the smallest unit according to the data region's data type, thus completing the deserialization process of the data to be deserialized. Since the deserialization operation is implemented in the Windows kernel, data security is improved.

[0104] Based on the above embodiments, when parsing the data to be deserialized, a breadth-first search algorithm can be used to prevent stack overflow during data serialization.

[0105] Figure 7 This is a schematic diagram of a data serialization device provided in an embodiment of this application. The device can be a module, program segment, or code on an electronic device. It should be understood that this device is similar to the one described above. Figure 1 The method implementation corresponds to this and can be executed. Figure 1 The various steps involved in the method embodiment, and the specific functions of the device, can be found in the description above. To avoid repetition, detailed descriptions are appropriately omitted here. The device includes: an acquisition module 701 and a node parsing module 702, wherein:

[0106] The obtaining module 701 is used to obtain the tree structure corresponding to the data to be serialized, wherein the leaf nodes in the tree structure are used to represent the smallest data unit, and the parent nodes in the tree structure are used to represent the data block containing the sub-data region;

[0107] The node parsing module 702 is used to traverse the tree structure and parse each node in the tree structure to obtain a parsing result; wherein, the parsing result is the result obtained after serializing the data to be serialized.

[0108] Based on the above embodiments, the node parsing module 702 is specifically used for:

[0109] Obtain the configuration file and constructor; wherein, the configuration file is used to identify the data type corresponding to the node; the constructor is used to parse the node whose data type has sub-data regions;

[0110] The leaf nodes in the tree structure are parsed according to the configuration file; the parent nodes in the tree structure are parsed according to the configuration file and the constructor.

[0111] Based on the above embodiments, the node parsing module 702 is specifically used for:

[0112] The data type corresponding to the node in the tree structure is determined according to the configuration file;

[0113] If the data type indicates that the node is the smallest unit of data, then the smallest unit of data is written to the cache.

[0114] Based on the above embodiments, the node parsing module 702 is specifically used for:

[0115] The data type corresponding to the node in the tree structure is determined according to the configuration file;

[0116] If the data type indicates that the node has sub-data regions, then the constructor is used to continue parsing the data regions until the smallest unit of data is obtained, and the smallest unit of data is written to the cache.

[0117] Based on the above embodiments, the node parsing module 702 is specifically used for:

[0118] The tree structure is traversed using a depth-first traversal algorithm.

[0119] Figure 8 This is a schematic diagram of a data deserialization device provided in an embodiment of this application. The device can be a module, program segment, or code on an electronic device. It should be understood that this device is similar to the one described above. Figure 4 The method implementation corresponds to this and can be executed. Figure 4 The various steps involved in the method embodiment, and the specific functions of the device, can be found in the description above. To avoid repetition, detailed descriptions are appropriately omitted here. The device runs in the Windows kernel of the electronic device and includes: an acquisition module 801, a data parsing module 802, and a generation module 803, wherein:

[0120] The acquisition module 801 is used to acquire the data to be deserialized and the corresponding configuration file;

[0121] The data parsing module 802 is used to parse the data to be deserialized according to the configuration file and generate a tree structure corresponding to the data to be deserialized.

[0122] The generation module 803 is used to generate deserialized data based on the tree structure.

[0123] Based on the above embodiments, the data parsing module 802 is specifically used for:

[0124] The multiple data regions contained in the data to be deserialized are obtained according to the configuration file;

[0125] If the data area has sub-data areas, the data area is written into the processing queue, and the data area is parsed again using the configuration file until the smallest unit of data is obtained.

[0126] Based on the above embodiments, the data parsing module 802 is specifically used for:

[0127] The multiple data regions contained in the data to be deserialized are obtained according to the configuration file using a breadth-first search algorithm.

[0128] Figure 9 This is a schematic diagram of the physical structure of the electronic device provided in the embodiments of this application, such as... Figure 9 As shown, the electronic device includes: a processor 901, a memory 902, and a bus 903; wherein,

[0129] The processor 901 and the memory 902 communicate with each other through the bus 903;

[0130] The processor 901 is used to call program instructions in the memory 902 to execute the methods provided in the above-described method embodiments, such as: obtaining a tree structure corresponding to the data to be serialized, wherein the nodes in the tree structure are used to represent the field information contained in the data to be serialized; traversing the tree structure and parsing each node in the tree structure to obtain a parsing result; wherein the parsing result is the result obtained after serializing the data to be serialized.

[0131] Obtain the data to be deserialized and the corresponding configuration file; parse the data to be deserialized according to the configuration file to generate a tree structure corresponding to the data to be deserialized; generate deserialized data based on the tree structure.

[0132] The processor 901 can be an integrated circuit chip with signal processing capabilities. The processor 901 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor.

[0133] The memory 902 may include, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0134] This embodiment discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by a computer, the computer can execute the methods provided in the above-described method embodiments, such as: obtaining a tree structure corresponding to data to be serialized, wherein nodes in the tree structure are used to represent field information contained in the data to be serialized; traversing the tree structure and parsing each node in the tree structure to obtain a parsing result; wherein the parsing result is the result obtained after serializing the data to be serialized. Or

[0135] Obtain the data to be deserialized and the corresponding configuration file; parse the data to be deserialized according to the configuration file to generate a tree structure corresponding to the data to be deserialized; generate deserialized data based on the tree structure.

[0136] This embodiment provides a non-transitory computer-readable storage medium storing computer instructions that cause the computer to execute the methods provided in the above-described method embodiments. These instructions include, for example, obtaining a tree structure corresponding to data to be serialized, where nodes in the tree structure represent field information contained in the data to be serialized; traversing the tree structure and parsing each node in the tree structure to obtain a parsing result; wherein the parsing result is the result obtained after serializing the data to be serialized. Alternatively...

[0137] Obtain the data to be deserialized and the corresponding configuration file; parse the data to be deserialized according to the configuration file to generate a tree structure corresponding to the data to be deserialized; generate deserialized data based on the tree structure.

[0138] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0139] Furthermore, the units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0140] Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0141] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.

[0142] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A method of data serialization, characterized by, The method runs in the Windows kernel of the electronic device and includes: Obtain the tree structure corresponding to the data to be serialized, wherein the nodes in the tree structure are used to represent the field information contained in the data to be serialized; The tree structure is traversed, and each node in the tree structure is parsed to obtain the parsing result; wherein, the parsing result is the result obtained after serializing the data to be serialized; The parsing of each node in the tree structure includes: Obtain the configuration file and constructor; wherein, the configuration file is used to identify the data type corresponding to the node; the constructor is used to parse the node whose data type has sub-data regions; The leaf nodes in the tree structure are parsed according to the configuration file; the parent nodes in the tree structure are parsed according to the configuration file and the constructor. The step of parsing the parent nodes in the tree structure according to the configuration file and the constructor includes: The data type corresponding to the node in the tree structure is determined according to the configuration file; If the data type indicates that the node has a sub-data region, then the constructor is used to continue parsing the data region until the smallest unit of data is obtained, and the smallest unit of data is written into the cache area; In the configuration file, the value following each field is used to characterize whether the node corresponding to that field is the smallest unit; wherein, the data of the smallest unit is located on the leaf node of the tree structure, and the data with sub-data regions is located on the parent node of the tree structure; and after parsing all nodes in the tree structure to the smallest unit of data and writing them into the buffer, the serialization of the data to be serialized is completed.

2. The method of claim 1, wherein, The step of parsing the leaf nodes in the tree structure according to the configuration file includes: The data type corresponding to the node in the tree structure is determined according to the configuration file; If the data type indicates that the node is the smallest unit of data, then the smallest unit of data is written to the cache.

3. The method according to any of claims 1-2, characterized in that, The traversal of the tree structure includes: The tree structure is traversed using a depth-first traversal algorithm.

4. A data deserialization method, characterized in that, The method runs in the Windows kernel of the electronic device and includes: Obtain the data to be deserialized and the corresponding configuration file; The data to be deserialized is parsed according to the configuration file to generate a tree structure corresponding to the data to be deserialized. Generate deserialized data based on the tree structure; The step of parsing the data to be deserialized according to the configuration file includes: The multiple data regions contained in the data to be deserialized are obtained according to the configuration file; If the data area has sub-data areas, the data area is written into the processing queue, and the data area in the processing queue is parsed again using the configuration file until the smallest unit of data is obtained. If the data region is the smallest unit of data, then the data region is inserted into the tree structure; The configuration file is a pre-generated file used to identify the data types of the fields contained in the data to be deserialized. The value following each field in the configuration file is used to characterize whether the node corresponding to that field is the smallest unit.

5. The method according to claim 4, characterized in that, The step of obtaining multiple data regions contained in the data to be deserialized according to the configuration file includes: The multiple data regions contained in the data to be deserialized are obtained according to the configuration file using a breadth-first search algorithm.

6. A data serialization device, characterized in that, The device runs on the Windows kernel of an electronic device and includes: The acquisition module is used to obtain the tree structure corresponding to the data to be serialized. The leaf nodes in the tree structure are used to represent the smallest data unit, and the parent nodes in the tree structure are used to represent the data block containing the sub-data region. The node parsing module is used to traverse the tree structure and parse each node in the tree structure to obtain the parsing result; wherein, the parsing result is the result obtained after serializing the data to be serialized; The node parsing module is specifically used for: Obtain the configuration file and constructor; wherein, the configuration file is used to identify the data type corresponding to the node; the constructor is used to parse the node whose data type has sub-data regions; The leaf nodes in the tree structure are parsed according to the configuration file; the parent nodes in the tree structure are parsed according to the configuration file and the constructor. The step of parsing the parent nodes in the tree structure according to the configuration file and the constructor includes: The data type corresponding to the node in the tree structure is determined according to the configuration file; If the data type indicates that the node has a sub-data region, then the constructor is used to continue parsing the data region until the smallest unit of data is obtained, and the smallest unit of data is written into the cache area; In the configuration file, the value following each field is used to characterize whether the node corresponding to that field is the smallest unit; wherein, the data of the smallest unit is located on the leaf node of the tree structure, and the data with sub-data regions is located on the parent node of the tree structure; and after parsing all nodes in the tree structure to the smallest unit of data and writing them into the buffer, the serialization of the data to be serialized is completed.

7. A data deserialization apparatus, characterized in that, The device runs on the Windows kernel of an electronic device and includes: The acquisition module is used to acquire the data to be deserialized and the corresponding configuration file; The data parsing module is used to parse the data to be deserialized according to the configuration file and generate a tree structure corresponding to the data to be deserialized. The generation module is used to generate deserialized data based on the tree structure; The data parsing module is specifically used for: The multiple data regions contained in the data to be deserialized are obtained according to the configuration file; If the data area has sub-data areas, the data area is written into the processing queue, and the data area in the processing queue is parsed again using the configuration file until the smallest unit of data is obtained. If the data region is the smallest unit of data, then the data region is inserted into the tree structure; The configuration file is a pre-generated file used to identify the data types of the fields contained in the data to be deserialized. The value following each field in the configuration file is used to characterize whether the node corresponding to that field is the smallest unit.

8. An electronic device, characterized in that, include: Processor, memory, and bus, among which, The processor and the memory communicate with each other via the bus; The memory stores program instructions that can be executed by the processor, and the processor can execute the method as described in any one of claims 1-5 by calling the program instructions.

9. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores computer instructions, which, when executed by a computer, cause the computer to perform the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Method for transmitting tree-structure object

    CN101876990A

  • Communication method and device based on GRPC communication protocol and electronic equipment

    CN116192950A