Object serialization method and apparatus, electronic device, and computer storage medium
By searching for or building serialization schemes in a pre-defined serialization scheme library, and selecting components based on object type and content, a serialization scheme can be dynamically constructed. This solves the problems of poor flexibility and weak scalability of existing object serialization schemes, and enables flexible adjustment and efficient expansion at runtime.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUHAN BAISIJIE TECH CO LTD
- Filing Date
- 2025-12-18
- Publication Date
- 2026-05-29
AI Technical Summary
Existing object serialization solutions are inflexible and have poor scalability, making them difficult to adapt to complex or changing business scenarios. Furthermore, when business requirements are modified, code needs to be modified and redeployed, increasing maintenance costs.
This provides an object serialization method that dynamically constructs a serialization scheme by searching for or building a serialization scheme in a preset serialization scheme library, selecting serialization scheme components based on object type and content, and supporting multiple schemes and visual configuration.
It achieves flexibility and scalability in serialization schemes, enabling dynamic adjustments during system runtime to adapt to various business scenario changes without redeployment, thus reducing system maintenance costs.
Smart Images

Figure CN121387289B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of object serialization technology, and more particularly to an object serialization method, apparatus, electronic device, and computer storage medium. Background Technology
[0002] In software development and data interaction, object serialization is a fundamental and crucial technology used to convert the state of an object into a storable or transmittable format (such as JSON, XML, etc.) to achieve data persistence or cross-system communication.
[0003] In existing technologies, common serialization methods include those based on the serialization mechanisms built into programming languages (such as Java's Serializable interface), serialization libraries based on fixed formats (such as Gson and Jackson), and hard-coded serialization logic, where developers explicitly specify the serialization method for each object in the code. However, these existing solutions have several problems and drawbacks. First, the serialization format is usually determined at runtime and cannot be dynamically adjusted during system operation, making it difficult to adapt to complex or changing business scenarios and exhibiting poor flexibility. Second, the same object type cannot use different serialization schemes for different business scenarios, resulting in serialization results that are either redundant or lack sufficient information, lacking a multi-scheme support mechanism. Furthermore, when business requirements change and require adding or modifying serialized content, code modification and redeployment are necessary, resulting in weak scalability and increased maintenance costs and system risks.
[0004] It is evident that existing object serialization schemes suffer from poor flexibility and limited scalability. Summary of the Invention
[0005] In view of this, it is necessary to provide an object serialization method, apparatus, electronic device, and computer storage medium to solve the problems of poor flexibility and weak scalability of existing object serialization schemes.
[0006] To address the aforementioned problems, in a first aspect, the present invention provides an object serialization method, comprising:
[0007] In response to a serialization request for an object to be serialized, the serialization scheme for the object to be serialized is searched in the preset serialization scheme library;
[0008] When a serialization scheme for the object to be serialized does not exist in the serialization scheme library, the serialization requirements of the object to be serialized are obtained. The serialization requirements include the object type and the content to be serialized of the object to be serialized.
[0009] Based on the object type and the content to be serialized, a serialization scheme component is selected from the preset serialization scheme component library. A serialization scheme for the object to be serialized is constructed based on the serialization scheme component, and the serialization operation is performed on the object to be serialized using the serialization scheme to obtain the serialization result.
[0010] In one possible implementation, searching for a serialization scheme for the object to be serialized in a preset serialization scheme library includes:
[0011] Based on the object type of the object to be serialized, search for the serialization scheme corresponding to the object type in the preset serialization scheme library;
[0012] The system searches for the corresponding serialization scheme in the serialization scheme library based on the object type of the object to be serialized and the serialization scheme name contained in the serialization request.
[0013] In one possible implementation, when a serialization scheme for the object to be serialized exists in the serialization scheme library, it includes:
[0014] Obtain the encapsulation file of the serialization scheme, and run the encapsulation file to perform serialization operations on the object to be serialized.
[0015] In one possible implementation, a serialization scheme component is selected from a preset serialization scheme component library based on the object type and the content to be serialized, and a serialization scheme for the object to be serialized is constructed based on the serialization scheme component, including:
[0016] The serialization scheme name, privacy identifier, and serialization elements of the object to be serialized are determined based on the object type. The serialization elements include attribute elements and associated elements.
[0017] Configure the element path and element name for attribute elements, and configure the association type and association name for associated elements.
[0018] In one possible implementation, for associated elements, it further includes:
[0019] Configure filters for associated elements, and the filters are used to filter associated data related to the associated elements.
[0020] In one possible implementation, a serialization scheme component is selected from a preset serialization scheme component library based on the object type and the content to be serialized, and a serialization scheme for the object to be serialized is constructed based on the serialization scheme component, including:
[0021] In the preset visualization interface, select the serialization scheme name, privacy identifier, and serialization element of the object to be serialized in the serialization content display area;
[0022] The serialized element content is displayed in the serialized element display area of the preset visual interface;
[0023] The serialization result of serializing the object using the serialization scheme is displayed in the serialization preview area of the preset visualization interface.
[0024] When a serialized element contains object-type properties, any of the following methods can be used to serialize the object-type properties:
[0025] Serialize object-type properties into unique identifiers;
[0026] Serialize object properties into a simplified object structure;
[0027] Serialize object properties into object key names;
[0028] Nested serialization is performed using a predefined serialization scheme for object-type properties.
[0029] In a second aspect, the present invention also provides an object serialization apparatus, comprising:
[0030] The serialization request receiving module is used to respond to the serialization request of the object to be serialized and search for the serialization scheme of the object to be serialized in the preset serialization scheme library.
[0031] The serialization requirements analysis module is used to obtain the serialization requirements of the object to be serialized when there is no serialization scheme for the object to be serialized in the serialization scheme library. The serialization requirements include the object type and the content to be serialized of the object to be serialized.
[0032] The serialization scheme determination module is used to select a serialization scheme component from a preset serialization scheme component library based on the object type and the content to be serialized, construct a serialization scheme for the object to be serialized based on the serialization scheme component, and perform serialization operation on the object to be serialized using the serialization scheme to obtain the serialization result.
[0033] Thirdly, the present invention also provides an electronic device, including a memory and a processor, wherein,
[0034] Memory, used to store programs;
[0035] A processor, coupled to memory, is used to execute a program stored in memory to implement the steps in the object serialization method of any of the above embodiments.
[0036] Fourthly, the present invention also provides a computer-readable storage medium for storing a computer-readable program or instructions, which, when executed by a processor, can implement the steps in the object serialization method of any of the above embodiments.
[0037] The beneficial effects of this invention are as follows: The object serialization method provided by this invention, upon receiving a serialization request for an object to be serialized, responds to the request by first searching for a corresponding serialization scheme in a preset serialization scheme library. If a serialization scheme exists for the object to be serialized, it can be directly reused. If no corresponding serialization scheme exists, the serialization requirements of the object to be serialized are obtained, including the object type and the content to be serialized. Based on the object type and the content to be serialized, a serialization scheme component is selected from the preset serialization scheme component library. A serialization scheme for the object to be serialized is constructed based on the serialization scheme component, and the serialization operation is performed on the object to be serialized using the serialization scheme to obtain the serialization result. By configuring the corresponding serialization scheme component according to the object type and the content to be serialized in the preset serialization component library, and constructing a complete serialization scheme, the serialization scheme component can be directly modified when the object type and the content to be serialized change. This makes the serialization scheme more flexible and has higher scalability. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a flowchart illustrating an object serialization method provided in an embodiment of the present invention;
[0040] Figure 2 A flowchart illustrating a serialization method construction method provided in an embodiment of the present invention;
[0041] Figure 3 A flowchart illustrating a visual method for constructing serialization is provided in an embodiment of the present invention.
[0042] Figure 4 A schematic diagram of a visual interface provided for an embodiment of the present invention;
[0043] Figure 5 This is a schematic diagram of the structure of an object serialization device provided in an embodiment of the present invention;
[0044] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0045] The preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which constitute a part of the present invention and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0046] In the description of the embodiments of the present invention, unless otherwise stated, "multiple" means two or more. "And / or" describes the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0047] The terms "first," "second," etc., used in the embodiments of this invention are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a technical feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature.
[0048] 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 the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0049] A specific embodiment of the present invention, such as Figure 1 As shown, an object serialization method is disclosed, including:
[0050] S101, in response to a serialization request for an object to be serialized, search for a serialization scheme for the object to be serialized in a preset serialization scheme library.
[0051] In this embodiment of the invention, the serialization scheme is the core definition of serialization, including important information such as the object type, scheme name, privacy identifier, and list of serialization elements. Serialization of the object to be serialized is achieved by encapsulating the serialization into a SchemaInfo object (SchemaInfo is a collection of metadata used to describe the structure and attributes of objects in a database or system). In this embodiment, a pre-set serialization scheme library is provided to store pre-built serialization schemes. When a serialization request for an object to be serialized is received, the serialization scheme for the object to be serialized is searched in the pre-set serialization scheme library. If the serialization scheme for the object to be serialized can be found directly, it can be used directly to serialize the object. How to find the serialization scheme corresponding to the object to be serialized in the serialization scheme library will be explained in detail later in this invention.
[0052] S102, when there is no serialization scheme for the object to be serialized in the serialization scheme library, obtain the serialization requirements of the object to be serialized. The serialization requirements include the object type and the content to be serialized of the object to be serialized.
[0053] In this embodiment of the invention, if a serialization scheme corresponding to the object to be serialized does not exist in the preset serialization scheme library, a serialization scheme for the object to be serialized needs to be constructed. Specifically, the serialization requirements of the object to be serialized are obtained, which include the object type and the content to be serialized. The object type of the object to be serialized is key information for determining the serialization scheme. Different types of objects to be serialized have different serialization schemes. The object type of the object to be serialized is determined based on the instance of the object to be serialized, such as "personnel," "items," and "resources." Furthermore, the content to be serialized may also differ for different types of objects to be serialized. For example, for an object of type "personnel," the content to be serialized may include name, gender, and age; for an object of type "items," the content to be serialized may include item material, item type, and item purpose. Of course, the content to be serialized for various types of objects to be serialized described above is only an example, and the specific content can be flexibly set according to actual needs.
[0054] S103. Based on the object type and the content to be serialized, select a serialization scheme component from the preset serialization scheme component library, construct a serialization scheme for the object to be serialized based on the serialization scheme component, and perform serialization operation on the object to be serialized using the serialization scheme to obtain the serialization result.
[0055] In this embodiment of the invention, based on the object type and content to be serialized of the object to be serialized determined in the foregoing embodiments, a corresponding serialization scheme component is selected from a preset serialization component library. This embodiment of the invention modularizes the serialization scheme, allowing for flexible adjustment of the serialization scheme components when expansion or adjustment is needed, making the selection of the serialization scheme more flexible. Specifically, the scheme name of the serialization scheme is determined according to the object type of the object to be serialized, and under this scheme name, the corresponding serialization scheme component is selected according to the content to be serialized of the object to be serialized, constructing a complete serialization scheme, encapsulating the serialization scheme, and using the serialization scheme to perform serialization operations on the object to be serialized to obtain the serialization result. When a serialization request for the same object to be serialized is received subsequently, the serialization scheme can be directly called for serialization. During the serialization execution phase, the system first looks up the corresponding serialization scheme ID (Identity document) based on the object type and scheme name. Then, it obtains the detailed information of the serialization scheme, including the definitions of all serialization elements. Next, the system traverses all serialization elements and performs corresponding serialization operations according to the type and configuration of each element. For attribute serialization elements, the system processes the attribute values according to the specified serialization method; for associated serialization elements, the system obtains the associated object and applies possible filters, then serializes the associated object using the referenced serialization scheme. Finally, all serialization results are combined into a complete serialization structure.
[0056] The object serialization method provided by this invention, upon receiving a serialization request for an object to be serialized, first searches for a corresponding serialization scheme in a preset serialization scheme library. If a serialization scheme exists for the object to be serialized, it can be directly reused. If no such scheme exists, the serialization requirements of the object to be serialized are obtained, including the object type and the content to be serialized. Based on the object type and the content to be serialized, a serialization scheme component is selected from a preset serialization scheme component library. A serialization scheme for the object to be serialized is constructed based on the serialization scheme component, and the serialization operation is performed on the object to be serialized using the serialization scheme to obtain the serialization result. By configuring the corresponding serialization scheme component according to the object type and the content to be serialized in the preset serialization component library, and constructing a complete serialization scheme, the serialization scheme component can be directly modified when the object type and the content to be serialized change. This makes the serialization scheme more flexible and has high scalability.
[0057] In some possible embodiments of the present invention, searching for a serialization scheme for the object to be serialized in a preset serialization scheme library includes:
[0058] Based on the object type of the object to be serialized, search for the serialization scheme corresponding to the object type in the preset serialization scheme library;
[0059] The system searches for the corresponding serialization scheme in the serialization scheme library based on the object type of the object to be serialized and the serialization scheme name contained in the serialization request.
[0060] In this embodiment of the invention, when searching for a serialization scheme corresponding to the object to be serialized in a preset serialization scheme library, the search can be conducted in several ways. On one hand, the serialization scheme can be searched in the preset serialization scheme library based on the object type of the object to be serialized. For example, if the object type of the object to be serialized is "personnel," then the serialization scheme corresponding to the object type "personnel" should be "personnel details," and the serialization scheme with the serialization name "personnel details" can be directly searched in the serialization scheme library. On the other hand, when some objects to be serialized submit a serialization request, the serialization request may contain the scheme name of the corresponding serialization scheme, and the corresponding serialization scheme can be directly searched in the serialization scheme library based on that serialization scheme name.
[0061] Furthermore, when it is determined that a serialization scheme for the object to be serialized exists in the serialization scheme library, this includes:
[0062] Obtain the encapsulation file of the serialization scheme, and run the encapsulation file to perform serialization operations on the object to be serialized.
[0063] In this embodiment of the invention, when it is determined that a serialization scheme exists in the serialization scheme library corresponding to the object to be serialized, the runtime encapsulation of the serialization scheme can be determined directly based on the object type of the object to be serialized and the name of the serialization scheme. The object to be serialized can be directly passed to a pre-loaded and constructed SchemaInfo object to perform serialization, providing maximum flexibility in scenarios with high performance requirements.
[0064] This invention provides a specific process for finding a serialization scheme for an object to be serialized in a serialization scheme library. The process involves searching for the corresponding serialization scheme by matching the object type of the object with the name of the corresponding serialization scheme, thus ensuring the accuracy of the serialization scheme search. When a serialization scheme corresponding to the object to be serialized exists in the serialization scheme library, the object can be serialized directly through runtime encapsulation of the serialization scheme, providing maximum flexibility in scenarios with high performance requirements.
[0065] In some possible embodiments of the present invention, such as Figure 2As shown, based on the object type and the content to be serialized, a serialization scheme component is selected from the preset serialization scheme component library. A serialization scheme for the object to be serialized is then constructed based on the serialization scheme component, including:
[0066] S201, determine the serialization scheme name, privacy identifier and serialization elements of the object to be serialized based on the object type, wherein the serialization elements include attribute elements and associated elements;
[0067] S201 configures the element path and element name for attribute elements, and configures the association type and association name for associated elements.
[0068] In this embodiment of the invention, when a serialization scheme corresponding to the object to be serialized does not exist in the preset serialization scheme library, a corresponding serialization scheme needs to be constructed. For ease of explanation, a specific embodiment is used as an example, taking the serialization of the object type "Person" as an example. Suppose we need to create a serialization scheme named "Person Details" for "Person," and this scheme needs to include the following:
[0069] 1) String attribute "code": Directly output its string value;
[0070] 2) String attribute "name": Directly outputs its string value;
[0071] 3) Object-type attribute "Organization" (org): This attribute points to an "Organization" object. During serialization, we only need to output the unique identifier (KEY) of this organization, therefore we choose the Key serialization method;
[0072] 4) Associate "Person Attendance": This is an association that links multiple attendance records through the "Person Attendance" type. We need to serialize all attendance records of the current person within a specific time period and apply an independent "Attendance Record" serialization scheme to each attendance record.
[0073] Furthermore, serialization elements include attribute elements and associated elements. Attribute elements are configured with element paths and names, while associated elements are configured with association types and names. Specifically, a "Person Details" scheme is created for the "Person" type. In the serialization scheme designer, the following four serialization elements are added: an attribute element with the attribute path "code" and name "ID"; an attribute element with the attribute path "name" and name "Name"; an attribute element with the attribute path "org" and name "Organization"; its serialization method is set to "Key"; and an associated element with the association type "PersonAttendance" and name "Recent Attendance". Specifically, its filter is set to "This Month's Attendance" to filter attendance data; and its referenced serialization scheme is set to "Attendance Records", applying an independent serialization scheme to each attendance record.
[0074] The above describes the construction of the serialization scheme for the object to be serialized. When a specific "person" object (e.g., Zhang San, ID EMP001) is serialized, the system will process it step by step according to the above scheme: Obtain Zhang San's "ID" attribute value "EMP001" and output it to the "ID" field of the JSON. Obtain Zhang San's "Name" attribute value "Zhang San" and output it to the "Name" field of the JSON. Obtain Zhang San's "Organization" attribute value (an organization object), and according to the configuration, extract only the organization's KEY "ORGKEY_01" and output it to the "Organization" field of the JSON. Based on the association configuration, find Zhang San's "Personnel Attendance" for this month. For each found attendance record, the system uses the referenced "Attendance Record" scheme to serialize it, ultimately forming an array of attendance records, which is output to the "Recent Attendance" field of the JSON. The final generated JSON structure is roughly as follows:
[0075] {
[0076] "ID": "EMP001",
[0077] Name: Zhang San
[0078] "Organization": "ORGKEY_01",
[0079] "Recent Attendance": [
[0080] {
[0081] Attendance Date: 2025-10-01
[0082] Attendance Status: "Normal"
[0083] },
[0084] {
[0085] Attendance Date: 2025-10-02
[0086] Attendance Status: "Late"
[0087] } ]
[0089] }
[0090] This invention determines the serialization scheme of the object to be serialized by the object type, the content to be serialized, and the serialization elements, and constructs a complete serialization scheme in the form of serialization scheme components, providing higher scalability and flexibility for the serialization scheme.
[0091] In some possible embodiments of the present invention, the related element further includes:
[0092] Configure filters for associated elements. Filters are used to filter associated data related to associated elements.
[0093] In this embodiment of the invention, for associated elements, because they are associated with or related to other data, filters need to be set to filter out the data that needs to be serialized. Taking the serialization scheme of the serialization object "Personnel" in the previous embodiment as an example, the association type of the associated element is "Personnel Attendance" and the name is "Recent Attendance". A filter is set for it, such as "This Month's Attendance", and a predefined "Attendance Record" serialization scheme is referenced (this scheme outputs the date and status of the attendance record).
[0094] This invention provides an embodiment of the invention that uses filters to ensure that the serialization scheme filters the data and prevents redundancy in the serialized information.
[0095] In some possible embodiments of the present invention, such as Figure 3 As shown, based on the object type and the content to be serialized, a serialization scheme component is selected from the preset serialization scheme component library. A serialization scheme for the object to be serialized is then constructed based on the serialization scheme component, including:
[0096] S301, in the serialization content display area of the preset visual interface, select the serialization scheme name, privacy identifier and serialization element of the object to be serialized;
[0097] S302, Display the element content of the serialized element in the serialized element display area of the preset visualization interface;
[0098] S303 displays the serialization result of the serialization of the serialization object using the serialization scheme in the serialization preview area of the preset visualization interface.
[0099] In this embodiment of the invention, when constructing a serialization scheme for an object to be serialized, it can be done through a visual interface, such as... Figure 4 As shown, this is a possible visualization interface for serialization, a graphical user interface tool with a left-right layout. The content design area on the left is further divided into upper and lower parts: the upper serialization scheme tree displays schemes and object types in a tree structure, providing a clear hierarchical view; the lower serialization scheme form is used to edit detailed attributes of schemes or elements. The effect display area on the right displays the serialization effect of the current scheme in real time, providing intuitive feedback to the user. Specifically, users can select the serialization scheme name, privacy identifier, and serialization elements of the object to be serialized in the preset serialization content display area of the visualization interface, such as... Figure 4 The upper left section is the serialized content display area. For a serialization scheme named "Personnel Details," the serialized content includes ID, name, organization, and recent attendance. When adjustments to the serialized content are needed, these can be made directly in this area, such as adding gender or deleting recent attendance records. Figure 4 The lower left section displays the serialization element for each serialized item. For example, for serialized content like "Recent Attendance," the associated attributes show the associated object type, name, sorting, serialization scheme, and filters. Furthermore, in... Figure 4 On the right, the serialization result of the serialization scheme for the object to be serialized can be displayed. Figure 4 This is merely an illustrative representation of the visual interface style of this invention; the specific style can be set according to actual circumstances.
[0100] The embodiments of the present invention construct serialization schemes through a visual interface, which is simple to operate and highly scalable.
[0101] In some possible embodiments of the present invention, when the serialized element contains an object-type property, the object-type property can be serialized using any of the following methods:
[0102] Serialize object-type properties into unique identifiers;
[0103] Serialize object properties into a simplified object structure;
[0104] Serialize object properties into object key names;
[0105] Nested serialization is performed using a predefined serialization scheme for object-type properties.
[0106] In this embodiment of the invention, there are some special cases where, when the serialized content is an object attribute, four different serialization methods are provided to meet the needs of different scenarios, including:
[0107] Key: A unique identifier that is serialized into an object;
[0108] KeyedName: The key name that is serialized into the object;
[0109] SItem: Serializes to a simplified object structure;
[0110] SerializationSchema: Uses a different serialization scheme for nested serialization.
[0111] Furthermore, regarding associated serialization, the system supports precise control over the associated objects to be serialized by setting filters, avoiding unnecessary data transmission. Simultaneously, by referencing other serialization schemes, deep serialization of associated objects can be achieved, maintaining the integrity of the data structure. In terms of dynamic configuration and real-time preview, the serialization scheme designer allows users to adjust the serialization scheme without system downtime and immediately see the changes through the real-time preview function, significantly improving the accuracy and efficiency of configuration.
[0112] The serialization scheme of this invention can be dynamically adjusted during system runtime, adapting to changing needs in various business scenarios without redeployment. Regarding multi-scheme support, multiple serialization schemes can be defined for the same object type, fully meeting serialization requirements in different scenarios. In terms of serialization efficiency, precise control of attributes and associated elements effectively avoids unnecessary data serialization, improving data processing and transmission efficiency. Regarding scalability, adding or modifying serialization elements does not require modifying the core code; configuration changes can be completed through the designer, significantly reducing system maintenance costs. Regarding ease of use, the serialization scheme designer provides an intuitive visual interface, coupled with real-time preview functionality, greatly lowering the technical barrier. Regarding complex data processing, nested serialization support enables efficient handling of complex object structures, maintaining data integrity and consistency.
[0113] To better implement the object serialization method in this embodiment of the invention, based on the object serialization method, correspondingly, such as... Figure 5 As shown, this embodiment of the invention also provides an object serialization apparatus, the object serialization apparatus 500 comprising:
[0114] The serialization request receiving module 501 is used to respond to the serialization request of the object to be serialized and search for the serialization scheme of the object to be serialized in the preset serialization scheme library.
[0115] The serialization requirement analysis module 502 is used to obtain the serialization requirements of the object to be serialized when there is no serialization scheme for the object to be serialized in the serialization scheme library. The serialization requirements include the object type and the content to be serialized of the object to be serialized.
[0116] The serialization scheme determination module 503 is used to select a serialization scheme component from a preset serialization scheme component library based on the object type and the content to be serialized, construct a serialization scheme for the object to be serialized based on the serialization scheme component, and perform serialization operation on the object to be serialized using the serialization scheme to obtain the serialization result.
[0117] The object serialization apparatus 500 provided in the above embodiments can implement the technical solutions described in the above object serialization method embodiments. The specific implementation principles of each module or unit can be found in the corresponding content in the above object serialization method embodiments, and will not be repeated here.
[0118] like Figure 6 As shown, the present invention also provides an electronic device 600. The electronic device 600 includes a processor 601, a memory 602, and a display 603. Figure 6 Only some components of the electronic device 600 are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
[0119] In some embodiments, processor 601 may be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run program code stored in memory 602 or process data, such as the object serialization method of the present invention.
[0120] In some embodiments, processor 601 may be a single server or a group of servers. The server group may be centralized or distributed. In some embodiments, processor 601 may be local or remote. In some embodiments, processor 601 may be implemented on a cloud platform. In some embodiments, the cloud platform may include a private cloud, public cloud, hybrid cloud, community cloud, distributed cloud, internal cloud, multi-cloud, or any combination thereof.
[0121] In some embodiments, memory 602 may be an internal storage unit of electronic device 600, such as a hard disk or memory of electronic device 600. In other embodiments, memory 602 may also be an external storage device of electronic device 600, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. equipped on electronic device 600.
[0122] Furthermore, the memory 602 may include both internal storage units of the electronic device 600 and external storage devices. The memory 602 is used to store application software and various types of data installed on the electronic device 600.
[0123] In some embodiments, display 603 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. Display 603 is used to display information from electronic device 600 and to display a visual user interface. Components 601-603 of electronic device 600 communicate with each other via a system bus.
[0124] In some embodiments, when processor 601 executes an object serialization program in memory 602, the following steps may be performed:
[0125] In response to a serialization request for an object to be serialized, the serialization scheme for the object to be serialized is searched in the preset serialization scheme library;
[0126] When a serialization scheme for the object to be serialized does not exist in the serialization scheme library, the serialization requirements of the object to be serialized are obtained. The serialization requirements include the object type and the content to be serialized of the object to be serialized.
[0127] Based on the object type and the content to be serialized, a serialization scheme component is selected from the preset serialization scheme component library. A serialization scheme for the object to be serialized is constructed based on the serialization scheme component, and the serialization operation is performed on the object to be serialized using the serialization scheme to obtain the serialization result.
[0128] It should be understood that when the processor 601 executes the object serialization program in the memory 602, in addition to the functions mentioned above, it can also perform other functions, as detailed in the description of the corresponding method embodiments above.
[0129] Furthermore, this embodiment of the invention does not specifically limit the type of electronic device 600 mentioned. Electronic device 600 can be a mobile phone, tablet computer, personal digital assistant (PDA), wearable device, laptop computer, or other portable electronic device. Exemplary embodiments of portable electronic devices include, but are not limited to, portable electronic devices running iOS, Android, Microsoft, or other operating systems. The aforementioned portable electronic device can also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the invention, electronic device 600 may not be a portable electronic device, but rather a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0130] Accordingly, embodiments of the present invention also provide a computer-readable storage medium for storing computer-readable programs or instructions. When the programs or instructions are executed by a processor, they can implement the steps or functions in the object serialization methods provided in the above-described method embodiments.
[0131] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0132] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. An object serialization method, characterized in that, include: In response to a serialization request for an object to be serialized, a serialization scheme for the object to be serialized is searched in a preset serialization scheme library; When the serialization scheme library does not contain a serialization scheme for the object to be serialized, the serialization requirements of the object to be serialized are obtained, and the serialization requirements include the object type and the content to be serialized of the object to be serialized. Based on the object type and the content to be serialized, a serialization scheme component is selected from the preset serialization scheme component library. A serialization scheme for the object to be serialized is constructed based on the serialization scheme component, and the serialization operation is performed on the object to be serialized using the serialization scheme to obtain the serialization result. The object type and the content to be serialized are selected from a preset serialization scheme component library. A serialization scheme for the object to be serialized is constructed based on the serialization scheme component, including: Based on the object type, the serialization scheme name, privacy identifier, and serialization elements of the object to be serialized are determined, wherein the serialization elements include attribute elements and associated elements; Configure the element path and element name for the attribute element, and configure the association type and association name for the associated element; The step of selecting a serialization scheme component from a preset serialization scheme component library based on the object type and the content to be serialized, and constructing a serialization scheme for the object to be serialized based on the serialization scheme component, includes: In the preset visualization interface, select the serialization scheme name, privacy identifier, and serialization element of the object to be serialized in the serialization content display area; The element content of the serialized element is displayed in the serialized element display area of the preset visualization interface; The serialization result of the serialization object using the serialization scheme is displayed in the serialization preview area of the preset visualization interface; When the serializable element contains an object-type property, the object-type property can be serialized using any of the following methods: Serialize the object-type attribute into a unique identifier; Serialize the object-type properties into a simplified object structure; Serialize the object-type attribute into the object's key name; Nested serialization is performed using a predefined serialization scheme for the object-type properties. The process involves selecting a serialization scheme component from a preset serialization scheme component library based on the object type and the content to be serialized, constructing a serialization scheme for the object to be serialized based on the serialization scheme component, and performing a serialization operation on the object to be serialized using the serialization scheme to obtain a serialization result, including: The serialization scheme is modularized, allowing for flexible adjustment of the serialization scheme components when expansion or adjustment is needed. During the serialization execution phase, the corresponding serialization scheme is found based on the object type and scheme name. The definition of the serialization element is determined according to the serialization scheme. The corresponding serialization operation is performed according to the type and configuration of each element. For attribute serialization elements, the attribute value is processed according to the specified serialization method. For associated serialization elements, the associated object is obtained and a filter is applied. The associated object is serialized using the referenced serialization scheme. Finally, all serialization results are combined into a complete serialization structure.
2. The object serialization method according to claim 1, characterized in that, The step of searching for the serialization scheme of the object to be serialized in the preset serialization scheme library includes: Based on the object type of the object to be serialized, a serialization scheme corresponding to the object type is searched in a preset serialization scheme library; Based on the object type of the object to be serialized and the serialization scheme name contained in the serialization request, the corresponding serialization scheme is searched in the serialization scheme library.
3. The object serialization method according to claim 1, characterized in that, When a serialization scheme for the object to be serialized exists in the serialization scheme library, it includes: Obtain the encapsulation file of the serialization scheme, and run the encapsulation file to perform serialization operation on the object to be serialized.
4. The object serialization method according to claim 1, characterized in that, For the aforementioned associated elements, it also includes: Configure a filter for the associated element, the filter being used to filter associated data related to the associated element.
5. An object serialization apparatus, applicable to the object serialization method according to any one of claims 1 to 4, characterized in that, include: The serialization request receiving module is used to respond to a serialization request of an object to be serialized by searching for a serialization scheme of the object to be serialized in a preset serialization scheme library. The serialization requirement analysis module is used to obtain the serialization requirements of the object to be serialized when there is no serialization scheme for the object to be serialized in the serialization scheme library. The serialization requirements include the object type and the content to be serialized of the object to be serialized. The serialization scheme determination module is used to select a serialization scheme component from a preset serialization scheme component library based on the object type and the content to be serialized, construct a serialization scheme for the object to be serialized based on the serialization scheme component, and perform a serialization operation on the object to be serialized using the serialization scheme to obtain a serialization result.
6. An electronic device, characterized in that, Including memory and processor, among which, The memory is used to store programs; The processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps in the object serialization method according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps in the object serialization method according to any one of claims 1 to 4.