Data processing method, device, electronic device and storage medium
Through reflection mechanism and annotation configuration, the flexibility and scalability of JavaBean objects and TLV format byte sequence conversion between POS terminal and server are solved, and efficient data conversion without third-party libraries is realized, and the data exchange process is simplified.
Patent Information
- Application Number
- CN202111656683.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-30
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2041-12-30
Smart Images

Figure CN114331416B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of electronic payment technology, and in particular, relates to a data processing method, device, electronic device and storage medium. Background Art
[0002] When POS (Point of sales, POS) terminals communicate with servers, they need to transmit exchange data, such as JavaBean objects, in the form of data sequences. How to provide a flexible and scalable method for converting exchange data and data sequences has become a problem that needs to be solved. Summary of the invention
[0003] The embodiments of the present application provide a data processing method, device, electronic device and storage medium, which can solve at least part of the above problems.
[0004] In a first aspect, an embodiment of the present application provides a method for data processing, including:
[0005] Get the target object;
[0006] Using the reflection mechanism, the annotation of each attribute of the target object is obtained in turn; the annotation contains the serialization parameters of the corresponding attribute;
[0007] For each attribute of the target object, based on the serialization parameter of the annotation corresponding to the attribute, convert the attribute into first serialized data;
[0008] Based on the first serialized data of each attribute, second serialized data corresponding to the target object is output.
[0009] It should be understood that in the embodiment of the present application, the annotation includes serialization parameters of each attribute of the target object, and uses the reflection mechanism to obtain the annotation of each attribute before serializing the target object, and converts the attribute into the first serialized data based on the serialization parameter of the annotation corresponding to the attribute. The conversion between the target object and the serialized data can be achieved without the need for a third-party dependent library, and because the serialization parameters configured in the annotation can be customized and adjusted, the flexibility of the conversion between the target object and the serialized data is improved.
[0010] In a second aspect, an embodiment of the present application provides a method for data processing, including:
[0011] Get the target serialized data;
[0012] Parsing the target serialized data to generate an identifier payload mapping table; the identifier payload mapping table includes the identifier of each attribute of the target object and the corresponding relationship between the first serialized data of the attribute; the target object is the object corresponding to the target serialized data;
[0013] Construct a target object using the reflection mechanism, and obtain annotations of each attribute of the target object in turn;
[0014] For each attribute of the target object, based on the identifier in the annotation corresponding to the attribute, the identifier payload mapping table is used to obtain the payload of the attribute, the payload is deserialized to obtain the value of the attribute, and the reflection mechanism is used to assign a value to the attribute;
[0015] Output the target object after each attribute is assigned a value.
[0016] In a third aspect, an embodiment of the present application provides a data processing device, including:
[0017] A target object acquisition module, used to acquire the target object;
[0018] An attribute annotation acquisition module is used to sequentially acquire the annotation of each attribute of the target object by using a reflection mechanism; the annotation includes serialization parameters of the corresponding attribute;
[0019] A first serialization module, configured to convert each attribute of the target object into first serialized data based on an indication parameter of an annotation corresponding to the attribute;
[0020] The second serialization module is used to generate second serialization data of the target object based on the first serialization data of each attribute.
[0021] In a fourth aspect, an embodiment of the present application provides a data processing device, including:
[0022] A serialized data acquisition module is used to acquire target serialized data;
[0023] An identification payload list generation module is used to parse the target serialized data and generate an identification payload mapping table; the identification payload mapping table contains the identification of each attribute of the target object and the corresponding relationship between the first serialized data of the attribute; the target object is the object corresponding to the target serialized data;
[0024] The attribute annotation acquisition module is used to construct the target object by using the reflection mechanism, and sequentially obtain the annotations of each attribute of the target object;
[0025] An attribute assignment module, for obtaining a payload of each attribute of a target object based on an identifier in an annotation corresponding to the attribute, using the identifier payload mapping table, deserializing the payload to obtain a value of the attribute, and assigning a value to the attribute using a reflection mechanism;
[0026] The target object output module is used to output the target object after each attribute is assigned a value.
[0027] In a fifth aspect, an embodiment of the present application provides an electronic device, including:
[0028] A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the method steps described in the first aspect or the second aspect.
[0029] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, including: the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in the first aspect or the second aspect are implemented.
[0030] In a seventh aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device executes the method steps described in the first aspect or the second aspect above.
[0031] It can be understood that the beneficial effects of the second to seventh aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0033] Figure 1 is a schematic diagram of a communication system provided by an embodiment of the present application;
[0034] Figure 2 This is a schematic diagram of serialization and deserialization provided by an embodiment of the present application;
[0035] Figure 3 It is a flowchart of a data processing method provided by an embodiment of the present application;
[0036] Figure 4 is a flowchart of a data processing method provided by another embodiment of the present application;
[0037] Figure 5 is a flowchart of a data processing method provided by another embodiment of the present application;
[0038] Figure 6 It is a flowchart of a data processing method provided by an embodiment of the present application;
[0039] Figure 7 is a flowchart of a data processing method provided by another embodiment of the present application;
[0040] Figure 8 This is a schematic diagram of a TLV nested data flow provided by an embodiment of the present application;
[0041] Fig. 9 is a flowchart of a data processing method provided by another embodiment of the present application;
[0042] Fig.10 It is a structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0043] Fig.11 It is a structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0044] Fig.12 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0046] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0047] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0048] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0049] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0050] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0051] Before describing the data processing method provided in the embodiment of the present application, in order to facilitate the understanding of the embodiment of the present application, the following Figure 1 and Figure 2 The principles of the data method provided in the embodiments of the present application and the related concepts involved in the embodiments of the present application are explained.
[0052] Figure 1 A communication system 10 provided in an embodiment of the present application is shown, and the communication system 10 includes a terminal device 110 and a server device 120 .
[0053] In some embodiments, the terminal device 110 may be a POS terminal, and the service-end device 120 may be a server.
[0054] The terminal device 110 and the server device 120 can communicate through a wired and / or wireless communication network. When the terminal device and the server device communicate, data needs to be transmitted and exchanged. When data needs to be transmitted and exchanged between the terminal device and the server device, for example, when sending a request message for a service and receiving and parsing the request message for the service, or when sending a response message and receiving and parsing the response message, the exchanged data needs to be serialized and deserialized to complete the communication.
[0055] Taking the exchange of data as Java objects as an example, the sender needs to convert the Java object into a byte sequence. After receiving the byte sequence, the receiver converts the byte sequence back to the Java object. The byte sequence is also called serialized data.
[0056] For an example of converting between a JavaBean object and a byte sequence in TLV (Tag-Length-Value) format, see Figure 2 Java serialization refers to the process of converting Java objects into TLV format byte sequences. Java deserialization refers to the process of restoring TLV format byte sequences to Java objects. JavaBeans are some portable, reusable Java classes that can be assembled into applications. TLV (Tag-Length-Value) format is an encoding method. The byte sequence of TLV includes three fields: tag field (Tag), length field (Length), and content field (Value).
[0057] As shown in FIG2 , JavaBean objects 210 and TLV format byte sequences 220 are mutually converted through a global data converter (TlvTransformer) 230. The global data converter 230 may be a program segment running on the terminal device 110 or the server device 120, or may be a processor unit configured on the terminal device 110 or the server device 120 for implementing serialization and deserialization.
[0058] For the convenience of description, the following embodiments refer to terminal devices and server devices collectively as electronic devices.
[0059] In the specific implementation manner of the present application, considering the flexibility and scalability of the data format when the POS terminal communicates with the server, a TLV (Tag-Length-Value) structure can be selected as a carrier for data interaction between the POS terminal and the server.
[0060] To facilitate understanding of the embodiments of the present application, the following embodiments of the present application are described by taking the exchange data as a JavaBean object and the structure of the serialized data as a TLV structure as an example.
[0061] It should be understood that the embodiments of the data processing method, device, electronic device, storage medium, etc. provided in the present application are also applicable to the serialization of exchange data of a programming language having a reflection mechanism and implementing an annotation function, and are also applicable to the structure of serialized data other than the TLV structure, such as the Varints structure or the ZigZag structure. Under the guidance of the embodiments of the present application, those skilled in the art can migrate the embodiments of the present application to the programming language used by them, or the serialization structure adopted by them without paying creative labor.
[0062] based on Figure 1 and Figure 2 In the above scenario, the applicant of the present application found that how to provide a flexible and scalable method for converting exchanged data and data sequences has become a problem to be solved. Specifically, in the data interaction scenario between the POS terminal and the server, how to convert the byte sequence in TLV format into a JavaBean object in a simpler, faster and more universal way, and how to convert the JavaBean object into a byte sequence in TLV format has become a problem to be solved.
[0063] Figure 3 The data processing method provided in the embodiment of the present application is shown, which is applied to the above Figure 1 The terminal device 110 or the server device 120 in the communication system 10 shown in the figure realizes the conversion of the data object into serialized data, which can be realized by the software and / or hardware of the terminal device 110 or the server device 120. Figure 3 As shown, the method includes steps S110 to S140. The specific implementation principle of each step is as follows:
[0064] S110, obtaining a target object.
[0065] In a possible implementation, the electronic device may use a global data converter to implement serialization. The input data of the global data converter is the target object to be serialized, and the output data of the global data converter is the serialized data of the target object.
[0066] It can be understood that the output data of the global data converter can be an array composed of serialized data or a data stream, which can be specifically implemented according to actual business needs.
[0067] In a specific example, the electronic device responds to a message that requires exchange of data transmission, calls a global data converter, and obtains a target object that needs to be serialized. The target object can be an instance of a JavaBean. The global data converter is a program segment that can perform serialization conversion on the target object, or a processing unit that implements the processing steps provided in the embodiment of the present application.
[0068] S120, using a reflection mechanism to sequentially obtain annotations of each attribute of the target object; the annotations include serialization parameters of the corresponding attributes.
[0069] Reflection is also called Reflection. Taking Java language as an example, reflection in Java language is to dynamically obtain information in a class (class information, method information, constructor information, field information, etc.) during runtime. In other words, the reflection mechanism enables the program to obtain all the information of an object during runtime.
[0070] Taking Java language as an example, annotation is a special "comment" placed before the class, method, field, and parameter of Java source code. The annotation will be directly ignored by the compiler, but the annotation can be packaged into the class file by the compiler. Therefore, annotation is a kind of "metadata" used for annotation. Annotation is a markup used by Java language for tool processing, and annotation can configure parameters.
[0071] After modifying members such as classes, methods, and variables with annotations, these annotations will not take effect on their own. To obtain the annotation information of a class, method, or variable, you must use Java reflection technology to obtain the Annotation object.
[0072] In some embodiments, the global data converter of the electronic device uses a reflection mechanism to sequentially obtain annotations of various attributes of the target object.
[0073] In a specific example, the global data converter uses the reflection mechanism Field[]fields=clazz.getDeclaredFields() for the instance Class clazz=People.class to obtain the annotations of each attribute of the object clazz in turn.
[0074] In the embodiment of the present application, the serialization parameters of the attribute are configured in each annotation of the target object. The serialization parameters are used to indicate the serialization rules of the global data converter or the local data converter.
[0075] In some specific embodiments, taking the exchange data as a JavaBean object and the structure of the serialized data as a TLV structure as an example, the custom annotation may include two types: TlvField and TlvListField.
[0076] The serialization parameters in the custom annotation TlvField can include at least one of the following parameters:
[0077] a) Tag, the label field in the TLV data;
[0078] b) Length, the length field in the TLV data;
[0079] c) PadChar, fill in bytes;
[0080] d)LeftPad, whether to pad on the left;
[0081] e)DataFormat, the date format of the date type field;
[0082] f)Scope: whether to perform serialization or deserialization when converting data;
[0083] g) Nested, whether it is a complex object;
[0084] h) Phase, customize the business request name whether to perform serialization or deserialization;
[0085] i)Handler, a SpringBean of a custom data converter, implements an instance of the local data converter interface class. Spring beans are objects managed by the Spring framework at runtime.
[0086] The serialization parameters in the custom annotation TLlvListFiled can include at least one of the following parameters:
[0087] a) Tag, the label field in the TLV data;
[0088] b) Size, the number of identical TLV data segments;
[0089] c) NestObject, the JavaBean type corresponding to a single TLV data segment;
[0090] d) Phase, customize the business request name whether to perform serialization or deserialization;
[0091] e)Scope: whether to perform serialization or deserialization during data conversion.
[0092] In some embodiments, the custom local data converter (TlvTransformHandler) is based on different data types and business requirements, and its conversion method is different. It is mainly used to convert complex attributes. In a specific example, it has two interfaces:
[0093] a) toBytes(object), converts the specified Java object into a byte array;
[0094] b) toObject(bytes), converts the specified byte array into a Java object.
[0095] The custom annotation TlvField is used to mark JavaBean basic properties or complex properties, which corresponds to a single TLV data segment; when marking complex properties, a custom layout data converter interface TlvTransformHandler can be configured to handle the conversion of complex data formats (data formats include but are not limited to TLV).
[0096] The custom annotation TlvListField is used to mark that the JavaBean property corresponds to a set of TLV data segments in the same format.
[0097] In some embodiments, the global data converter (TlvTransformer) uses the annotations and converters defined above to define a complete data conversion process to achieve mutual conversion between JavaBean and TLV data.
[0098] In some embodiments, before applying the data processing method provided by the embodiments of the present application, that is, before obtaining the target object, it also includes configuring annotations (Annotation) for the attribute fields of the type (JavaBean).
[0099] S130 , for each attribute of the target object, convert the attribute into first serialized data based on a serialization parameter of an annotation corresponding to the attribute.
[0100] In some embodiments, the global data converter traverses each attribute of the target object and processes each attribute of the target object.
[0101] In a specific example, the serialization parameters include the two parameters Tag and Length defined in the above annotation. The global data converter assigns a value to the Tag field of the TLV byte sequence of the attribute according to Tag, assigns a value to the Length field of the TLV byte sequence of the attribute according to Length, and serializes the attribute into a byte sequence, that is, the first serialized data, which is stored in the Value field of the TLV sequence of the attribute.
[0102] In another specific example, the serialization parameters include the above-mentioned Tag and Handler parameters, where Handler is a local data converter. The local data converter is a special serialization converter designed for such Java objects, which will create corresponding Java objects in view of different data types and business requirements. Because it only acts on the object attributes in the target object, it can be called a local data converter. The global data converter assigns a value to the Tag field of the TLV sequence of the attribute according to the Tag parameter, and the Handler serializes the object attribute to obtain the first serialized data, which is stored in the Value field of the TLV sequence of the attribute.
[0103] The input of the Handler is the attribute of the target object, and the output is the byte sequence corresponding to the attribute, that is, the first serialized data.
[0104] In some embodiments, the local data converter may have preset rules for serializing attributes according to different business needs, and the local data converter serializes the attributes according to the rules.
[0105] In other embodiments, the attribute of the target object may be an instance of another class, that is, another object. It is understandable that the attribute in the other object may also have annotations. The Handler may perform serialization conversion on the other object according to the annotations in the other object. The principle of the conversion is the same as the principle of the global data converter serializing the target object.
[0106] In yet another specific example, the annotation includes at least one of the padding indication parameters PadChar or LeftPad; the method further includes: padding the first serialized data based on the padding indication parameter.
[0107] For example, in the annotation @TlvField(tag=0x0011,length=7,padChar="X",scope=TlvField.Scope.OUTPUT), the data length is defined as 7, and if it is insufficient, it is padded with the specified character "X". The length of the byte array of some attribute serialization is fixed, so it needs to be padded if it is insufficient. In the embodiment of the present application, a padding indication parameter is added to the annotation, and when the attribute with the annotation is serialized, the padding is performed according to the padding indication parameter.
[0108] It can also be seen in this example that this annotation contains a serialization switch parameter Scope. The method also includes: determining whether to perform serialization or deserialization during data conversion through the serialization switch parameter. TlvField.Scope.OUTPUT defines through Scope that this attribute is only serialized when it is returned to the calling end, that is, when the value is OUTPUT. Some attributes only need to be used in business processing, but do not need to be serialized and returned to the caller, and vice versa. The embodiment of the present application uses a serialization switch parameter to implement whether to perform serialization or deserialization.
[0109] In another specific example, the annotation includes a date format parameter DataFormat; the method further includes, according to the date format parameter, converting a given date string into a date object according to the format. The date setting type is set through an attribute, for example, dateFormat = "yyyyMMddHHmmss".
[0110] It can be seen from the above several specific examples that the embodiments of the present application can achieve length padding, date format setting and whether to perform serialization or deserialization during serialization through annotation.
[0111] S140: Generate second serialized data corresponding to the target object based on the first serialized data of each attribute.
[0112] In some embodiments, the global data converter combines the first serialized data of each attribute of the target object according to preset rules, for example, combining them in the order of the attributes, to generate second serialized data corresponding to the target object. In some specific examples, the combination process according to preset rules may also include encapsulating the first serialized data according to protocol rules. Specifically, the second serialized data may be a combination of the first serialized data, and a tag field and a length field are added to the first serialized data to form TLV format data, for example, an array of byte sequences in TLV format, or a byte stream of byte sequences in TLV format.
[0113] It should be understood that in the embodiment of the present application, the annotation includes serialization parameters of each attribute of the target object, and uses the reflection mechanism to obtain the annotation of each attribute before serializing the target object, and converts the attribute into the first serialized data based on the serialization parameter of the annotation corresponding to the attribute. The conversion between the target object and the serialized data can be achieved without the need for a third-party dependent library, and because the serialization parameters configured in the annotation can be customized and adjusted, the flexibility of the conversion between the target object and the serialized data is improved.
[0114] The specific embodiment of the present application provides a new technical implementation based on Java Annotation and reflection mechanism to realize the conversion between JavaBean and TLV data formats. By configuring Annotation on the attribute field of JavaBean, the conversion between JavaBean and TLV data formats can be realized without using a third-party dependency library, and because the serialization parameters in the annotation can be customized and adjusted, the flexibility of the conversion between the target object and the serialized data is improved.
[0115] In the above Figure 3 On the basis of the embodiment of the data processing method shown, the attributes of the target object are classified into simple attributes and complex attributes.
[0116] Simple attributes are attributes defined based on basic data types, including but not limited to data types such as integer data types, floating-point data types, character data types, and string data types defined in programming language specifications.
[0117] Complex attributes are attributes defined based on custom objects, including but not limited to various attributes defined according to business needs.
[0118] Based on this, in step S130, based on the serialization parameter of the annotation corresponding to the attribute, the attribute is converted into the first serialized data, such as Figure 4 As shown, it includes steps S131 to S133:
[0119] S131: Determine the attribute type of the attribute.
[0120] In some embodiments, the attribute type of the attribute may be determined based on how the attribute is defined.
[0121] In other embodiments, the attribute type of the attribute may be determined according to a type parameter in the annotation.
[0122] In some specific examples, the type of the corresponding attribute can be determined by the annotation name, and a parameter identifying the attribute type can be set in the annotation to indicate the attribute type.
[0123] In other specific examples, the attribute type of the attribute may also be determined by determining type parameters that only complex attributes have, such as parameters such as Handler or NestObject.
[0124] S132: If the attribute type is a simple attribute, directly convert the simple attribute into the first serialized data according to the serialization parameters in the annotation.
[0125] In some embodiments, if the global data converter determines that the attribute type is a simple attribute, such as an integer data type or a string data type, or other data types defined by a language specification, the simple attribute is directly converted into the first serialized data. Specifically, the simple attribute can be directly converted into the first serialized data using a serialization function provided by a programming language, such as Java.
[0126] In some specific examples, for a simple attribute, the tag field and length field of the attribute converted into the TLV format are determined according to the Tag and Length parameters in the annotation.
[0127] For example, the annotation @TlvField(tag=0x0088,length=7) of the attribute private String responseCode defines the tag (Tag) "0x0088" and length (Length) "7" that are converted to a TLV byte sequence. The global data converter serializes the parameters accordingly, converts the responseCode attribute to a byte sequence of length "7", and sets the tag field of the TLV structure corresponding to this attribute to "0x0088" according to the "tag" value in the annotation.
[0128] S133: If the attribute type is a complex attribute, call a local data converter corresponding to the attribute in the annotation to convert the attribute into the first serialized data.
[0129] In some embodiments, if the attribute type is a complex attribute, such as a class defined according to business needs, a local data converter corresponding to the attribute in the annotation is called to convert the attribute into the first serialized data. The serialization converter for a specific attribute is a local data converter.
[0130] In a specific example, the complex property private List <customizedapplicationinfo>The annotation @TlvField(tag=0x0099,handlerBeanName="bpsCustomizedAppInfoHandler") of applicationList includes a parameter handlerBeanName="bpsCustomizedAppInfoHandler", which is used to instruct the global data converter to call the local data converter bpsCustomizedAppInfoHandler to serialize the applicationList attribute to obtain the first serialized data.
[0131] In another specific example, a complex property is a private List of data of the same type. <updatefileinfo>The annotation @TlvListField(tag=0x0077, nestedObject=UpdateFileInfo.class, size=10) of updateFileInfoList calls the local data converter corresponding to the nested class UpdateFileInfo.class to perform serialization conversion on the updateFileInfoList attribute to obtain the first serialized data.
[0132] It should be noted that when processing the conversion of complex attribute data formats, the data formats include but are not limited to TLV formats, that is, local data converters can be used to convert attributes into byte sequences of other data formats required by specific business needs.
[0133] In some embodiments, calling the serialization converter corresponding to the complex attribute in the annotation to convert the complex attribute into the first serialized data includes: taking the complex attribute as the target object, calling the local data converter to perform Figure 3 In the method shown, from the step of acquiring the target object to the step of generating the second serialized data of the target object, that is, step S110 to step S140, the second serialized data is used as the first serialized data, and the converter outputs the first serialized data. It can be understood that the embodiment of the present application can not only process basic attributes and complex attributes, but also nested complex attributes.
[0134] It is understandable that the embodiment of the application can realize the data conversion of the basic attributes defined by the language and the customized complex attributes through annotation. In addition, through annotation, a customized local data converter is specified for the complex attributes to realize the mutual conversion between JavaBean and other data formats.
[0135] In order to better understand the embodiments of the present application, as an example rather than a limitation, Figure 5 A specific implementation of the present application is shown to facilitate understanding of the deserialization data processing method provided in the embodiment of the present application.
[0136] The process of converting JavaBean objects into TLV data:
[0137] 1. Define annotations, which are used to mark the properties of the JavaBean object and the corresponding Tag-Length information. If it is a complex object, the class information of the complex object is also required.
[0138] 2. Use the Annotation defined in step 1 to mark the attributes of the object to be converted.
[0139] 3. Call the global data converter (TlvTransformer) to convert the specified JavaBean into a TLV byte array.
[0140] 4. When receiving a JavaBean object, TlvTransformer uses the reflection mechanism to read the TLV-related annotation information (if any) of the attributes in turn.
[0141] 5. For simple attributes (such as numbers, strings, etc.), the Value information of the TLV byte sequence is directly serialized. If it is a complex attribute, the corresponding local data converter of the attribute is called to convert it into TLV or other format data as the Value information.
[0142] Figure 6 The data processing method provided in the embodiment of the present application is shown, which is applied to the above Figure 1 The terminal device 110 or the server device 120 in the communication system 10 shown in the figure implements the deserialization conversion of the data sequence to the data object, which can be implemented by the software and / or hardware of the terminal device 110 or the server device 120. Figure 6 As shown, the method includes steps S210 to S250. The specific implementation principle of each step is as follows:
[0143] S210, obtaining target serialization data.
[0144] In a possible implementation, the electronic device can still use the global data converter provided in the above embodiment to implement deserialization. The input data of the global data converter is the target serialized data to be deserialized, and the output data of the global data converter is the target object corresponding to the target serialized data.
[0145] It is understandable that a separate global data converter for deserialization may also be used for implementation, and its implementation principle is the same as that of each embodiment of the present application.
[0146] In a specific example, in response to a message that data exchange transmission is required, the electronic device calls a global data converter to obtain target serialized data that needs to be deserialized.
[0147] The target serialized data can be data with a TLV (Tag-Length-Value) structure, or a byte sequence with other structures.
[0148] The global data converter is a program segment that can perform deserialization conversion on the target serialized data, or a processing unit that implements the processing steps provided in the embodiments of the present application.
[0149] S220, parsing the target serialized data to generate an identifier payload mapping table; the identifier payload mapping table includes the identifier of each attribute of the target object and the corresponding relationship between the first serialized data of the attribute; the target object is the object corresponding to the target serialized data.
[0150] In some embodiments, the electronic device parses the target serialized data, extracts the payload data in the target serialized data, and the identifier corresponding to the payload data, and maps the corresponding relationship between the payload identifier and the payload to a payload mapping table. The payload generally refers to the pure information part of the cell of the communication protocol, excluding the header. In an embodiment of the present application, the payload is the first serialized data obtained by converting the attributes of the target object. In the TLV format, the identifier is the value of the Tag field, and the payload is the value of the Value field.
[0151] In some specific examples, the payload mapping table may be a data table consisting of key-value pairs. In some specific examples, the payload identifier and the payload are stored in the identifier-payload mapping table in the order of the target serialized data. In another specific example, the payload identifier and the payload pointer may also be stored in the identifier-payload mapping table.
[0152] In a specific example, after receiving a TLV data stream, the electronic device converts the data stream into a TLV container object, which maintains a Tag-Value mapping table. The TLV data format definition consists of Tag-Length-Value, and the mapping relationship after parsing the TLV data is the mapping relationship between Tag and Value. The Tag corresponds to the identifier of each attribute of the target object, and the Value corresponds to the first serialized data of each attribute.
[0153] S230, constructing a target object using a reflection mechanism, and sequentially obtaining annotations of various attributes of the target object.
[0154] It will be appreciated that the type of target object may be determined in several different ways.
[0155] In some embodiments, the type of the target object may be determined in a pre-specified manner.
[0156] In other embodiments, the type of the target object can also be determined by relevant parameters in the business processing flow, for example, it can be determined based on the type of message received; for example, it can be determined based on a serialization ID, such as serialVersionUID in Java; for example, the type corresponding to the target serialized data currently required to be parsed can be determined through the business process; for example, it can be determined by the corresponding type identification information carried in the TLV data stream.
[0157] In a specific example, after determining the type of a target object, a global data converter in an electronic device can use a reflection mechanism to construct an instance of the target object, that is, the target object, and sequentially obtain annotations of various attributes of the target object.
[0158] S240, for each attribute of the target object, based on the identifier in the annotation corresponding to the attribute, use the identifier payload mapping table to obtain the payload of the attribute, deserialize the payload to obtain the value of the attribute, and assign a value to the attribute using a reflection mechanism.
[0159] In some embodiments, the identifier in the annotation can be a Tag parameter of the above annotation parameter. Since the mapping relationship between Tag and Value is stored in the identifier payload mapping table, the global data converter of the electronic device can retrieve the payload of the attribute in the identifier payload mapping table for each attribute of the target object based on the identifier in the annotation corresponding to the attribute. After obtaining the payload of the attribute, the payload is deserialized to obtain the value of the attribute, and the reflection mechanism is used to assign a value to the attribute.
[0160] Corresponding to the above Figure 3 In some specific implementations of the illustrated embodiments, when deserializing the payload to obtain the value of the attribute, the padded payload may be de-padded according to the parameters in the annotation. The payload may be deserialized according to the date format parameter in the annotation. Whether the payload needs to be deserialized may be determined according to the serialization switch parameter.
[0161] S250, outputting the target object after each attribute is assigned a value.
[0162] In some implementations, after each attribute is assigned a value, the global data converter outputs the target object, completing the deserialization operation of converting the target serialized data into the target object.
[0163] It should be understood that Figure 6 In the illustrated embodiment, since the target serialization data is pre-parsed to generate an identifier-payload mapping table, and the identifier-payload mapping table is used to obtain the payload of the attribute based on the identifier in the annotation, the problem of low operating efficiency caused by repeated queries of the target serialization data when the program is running is avoided.
[0164] In the above Figure 6 On the basis of the embodiment of the data processing method shown, the attributes of the target object are classified into simple attributes and complex attributes.
[0165] Simple attributes are attributes defined based on basic data types, including but not limited to integer data types, floating-point data types, character data types, and string data types defined in programming language specifications.
[0166] Complex attributes are attributes defined based on custom objects, including but not limited to various attributes defined according to business needs.
[0167] In step S240, the payload is deserialized to obtain the value of the attribute, and the reflection mechanism is used to assign the value to the attribute, such as Figure 7 As shown, it includes steps S241 to S243:
[0168] S241: Determine the attribute type of the attribute.
[0169] In some embodiments, the attribute type of the attribute may be determined according to the definition of the attribute. In other embodiments, the attribute type of the attribute may be determined according to the type parameter in the annotation.
[0170] In some specific examples, the type of the corresponding attribute can be determined by the annotation name, and a parameter identifying the attribute type can be set in the annotation to indicate the attribute type.
[0171] In other specific examples, the attribute type of the attribute may also be determined by determining type parameters that only complex attributes have, such as parameters such as Handler or NestObject.
[0172] S242: If the attribute type is a simple attribute, the payload is directly deserialized to obtain the value of the simple attribute, and the reflection mechanism is used to assign a value to the attribute.
[0173] In some embodiments, if the global data converter determines that the attribute type is a simple attribute, such as an integer data type or a string data type, or other data types defined by the language specification, the payload, such as the Value in the TLV format corresponding to the attribute, can be directly deserialized to obtain the value of the attribute.
[0174] In some specific examples, direct deserialization conversion can be performed using a programming language, such as Java, to provide a deserialization function to perform conversion, and the payload is directly deserialized to obtain the value of the simple attribute. After obtaining the value of the attribute, the global data converter uses a reflection mechanism to assign a value to the attribute.
[0175] S243: If the attribute type is a complex attribute, call the local data converter corresponding to the attribute, deserialize the payload to obtain the value of the attribute, and assign the value to the attribute using a reflection mechanism.
[0176] In some embodiments, if the attribute type is a complex attribute, such as an attribute customized by a user according to business needs, a local data converter corresponding to the attribute in the annotation is called to deserialize the payload to obtain the value of the attribute. A local data converter is a converter that acts on an attribute.
[0177] In some specific examples, the local data converter presets conversion rules to deserialize the payload to obtain the value of the attribute. In some cases, even if the target serialized data is a TLV byte sequence, the value in the Value field can be a non-TLV byte sequence, which can be converted into the attribute of the target object by the local data converter according to the preset rules. It can be understood that, corresponding to different business needs, the corresponding serialization rules can be customized for the business needs, and the serialization and deserialization conversion can be realized by the local data converter according to the preset rules.
[0178] In some embodiments, Figure 8 As shown, the TLV data stream is a nested structure, also known as a composite data element structure. That is, the TLV data contains Tag, Length, and Value fields, where the serialized data in one or more Value fields is itself the serialized data of another object, that is, the TLV data of another object.
[0179] In view of this situation, in an embodiment provided by the present application, a local data converter corresponding to the attribute is called, the payload is deserialized to obtain the value of the attribute, and the reflection mechanism is used to assign the value to the attribute, including:
[0180] Using the payload as the target serialized data, the deserialization converter performs the following operations: Figure 6 In the method shown, from the steps of acquiring the target serialized data to the steps of outputting the target object after each attribute is assigned a value, that is, steps S210 to S250, the target object is used as the value of the attribute, and the reflection mechanism is used to assign values to the attribute.
[0181] It should be understood that this implementation can specify a custom data converter for a JavaBean property, can implement mutual conversion between JavaBean and other data formats, and can also implement conversion of nested serialized data.
[0182] In order to better understand the embodiments of the present application, as an example rather than a limitation, Fig. 9 A specific implementation of the present application is shown to facilitate understanding of the deserialization data processing method provided in the embodiment of the present application.
[0183] The process of converting TLV into JavaBean data:
[0184] 1. After receiving the TLV data stream, the server converts it into a TLV container (TLVBox) object through the parser. The TLVBox object maintains a Tag-Value mapping table.
[0185] 2. Call the global data converter TlvTransformer to convert the TLV byte sequence data into a JavaBean object of the specified type.
[0186] 3. According to the specified Class type, the JavaBean instance is constructed through reflection technology, and the TLV-related Annotation information of the attributes (if any) is read in turn.
[0187] 4. According to the Tag information in the Annotation, obtain the corresponding Value from the Tag-Value mapping table maintained by TLVBox.
[0188] 5. For simple objects (such as numbers, strings, etc.), deserialize them directly and assign values to the corresponding attributes using reflection. For complex objects, repeat the above process 1 to 5 to complete the instantiation, and then assign values to the corresponding attributes using reflection.
[0189] 6. After all the attributes marked with TlvField or TlvListField have gone through steps 4 and 5, the JavaBean instance object is output to complete the conversion.
[0190] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0191] Corresponding to the above Figure 3 The data processing method shown, Fig.10 The figure shows a data processing device M100 provided in an embodiment of the present application, including:
[0192] The target object acquisition module M110 is used to acquire the target object.
[0193] The attribute annotation acquisition module M120 is used to use the reflection mechanism to sequentially acquire the annotation of each attribute of the target object; the annotation includes the serialization parameters of its corresponding attribute.
[0194] The first serialization module M130 is used to convert each attribute of the target object into first serialization data based on the indication parameter of the annotation corresponding to the attribute.
[0195] The second serialization module M140 is used to generate second serialization data of the target object based on the first serialization data of each attribute.
[0196] Optionally, the first serialization module includes: an attribute type determination module, used to determine the attribute type of the attribute. A simple attribute serialization module, used to directly convert the simple attribute into the first serialized data according to the serialization parameters in the annotation if the attribute type is a simple attribute. A complex attribute serialization module, used to call the serialization converter corresponding to the attribute in the annotation to convert the attribute into the first serialized data if the attribute type is a complex attribute. The simple attribute is an attribute defined based on a basic data type, and the complex attribute is an attribute defined based on a custom object.
[0197] Optional, complex attribute serialization module, including:
[0198] A complex attribute nesting processing module is used to take the complex attribute as the target object and call the converter to implement Fig. 9 In the device, the module from acquiring the target object to generating the second serialized data of the target object uses the second serialized data as the first serialized data, and the converter outputs the first serialized data.
[0199] Corresponding to the above Figure 6 The data processing method shown, Fig.11 The figure shows a data processing device M200 provided in an embodiment of the present application, including:
[0200] The serialization data acquisition module M210 is used to acquire target serialization data.
[0201] The identification payload list generating module M220 is used to parse the target serialized data and generate an identification payload mapping table; the identification payload mapping table includes the identification of each attribute of the target object and the corresponding relationship between the first serialized data of the attribute; the target object is the object corresponding to the target serialized data;
[0202] The attribute annotation acquisition module M230 is used to construct a target object using a reflection mechanism, and sequentially acquire annotations of various attributes of the target object;
[0203] The attribute assignment module M240 is used for obtaining the payload of each attribute of the target object based on the identifier in the annotation corresponding to the attribute by using the identifier payload mapping table, deserializing the payload to obtain the value of the attribute, and assigning the value to the attribute by using the reflection mechanism;
[0204] The target object output module M250 is used to output the target object after each attribute is assigned a value.
[0205] Optionally, the attribute assignment module includes: an attribute type module, which is used to determine the attribute type of the attribute. A simple attribute deserialization module, which is used to directly deserialize the payload to obtain the value of the simple attribute if the attribute type is a simple attribute, and use the reflection mechanism to assign a value to the attribute. A complex attribute deserialization module, which is used to call the deserialization converter corresponding to the attribute if the attribute type is a complex attribute, deserialize the payload to obtain the value of the attribute, and use the reflection mechanism to assign a value to the attribute. The simple attribute is an attribute defined based on a basic data type, and the complex attribute is an attribute defined based on a custom object.
[0206] Optionally, a complex attribute deserialization module includes: using the payload as the target serialization data, and the deserialization converter implements Figure 6 In the device, from the step of acquiring target serialized data to the step of outputting the target object after each attribute is assigned a value, the target object is used as the value of the attribute, and the reflection mechanism is used to assign values to the attributes.
[0207] It can be understood that the various implementation modes and implementation combinations in the above embodiments and their beneficial effects are also applicable to this embodiment and will not be described in detail here.
[0208] Fig.12 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Fig.12 As shown, the electronic device D10 of this embodiment includes: at least one processor D100 ( Fig.12 Only one processor, a memory D101, and a computer program D102 stored in the memory D101 and executable on the at least one processor D100 are shown in the figure. When the processor D100 executes the computer program D102, the steps in any of the above-mentioned method embodiments are implemented.
[0209] The electronic device D10 may be a computing device such as a POS terminal, a desktop computer, a notebook, a PDA, or a cloud server. The electronic device may include, but is not limited to, a processor D100 and a memory D101. Those skilled in the art will appreciate that Fig.12 This is only an example of the electronic device D10 and does not constitute a limitation on the electronic device D10. The electronic device D10 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0210] The processor D100 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0211] In some embodiments, the memory D101 may be an internal storage unit of the electronic device D10, such as a hard disk or memory of the electronic device D10. In other embodiments, the memory D101 may also be an external storage device of the electronic device D10, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device D10. Further, the memory D101 may also include both an internal storage unit of the electronic device D10 and an external storage device. The memory D101 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program, etc. The memory D101 may also be used to temporarily store data that has been output or is to be output.
[0212] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0213] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0214] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0215] An embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0216] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0217] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0218] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0219] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0220] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0221] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.< / updatefileinfo> < / customizedapplicationinfo>
Claims
1. A method for data processing, characterized in that: include: Get the target object; Using the reflection mechanism to obtain the annotation of each attribute of the target object in turn; The annotation contains serialization parameters of its corresponding attributes; The serialization parameter is used to indicate the serialization rule of the global data converter or the local data converter; For each attribute of the target object, based on the serialization parameters of the annotation corresponding to the attribute, converting the attribute into first serialized data, including: determining the attribute type of the attribute; if the attribute type is a simple attribute, directly converting the simple attribute into the first serialized data based on the serialization parameters in the annotation; if the attribute type is a complex attribute, calling the local data converter corresponding to the attribute in the annotation to convert the attribute into the first serialized data; the simple attribute is an attribute defined based on a basic data type, and the complex attribute is an attribute defined based on a custom object; Based on the first serialized data of each attribute, output second serialized data corresponding to the target object; Calling the local data converter corresponding to the attribute in the annotation to convert the attribute into the first serialized data, including: taking the complex attribute as the target object, calling the local data converter to execute the steps from obtaining the target object to generating the second serialized data of the target object, taking the second serialized data as the first serialized data, and the local data converter outputting the first serialized data.
2. A method for data processing, characterized in that: include: Get the target serialized data; Parsing the target serialized data to generate an identification payload mapping table; The identifier payload mapping table includes a corresponding relationship between an identifier of each attribute of the target object and the first serialized data of the attribute; The target object is the object corresponding to the target serialized data; Construct a target object using the reflection mechanism, and obtain annotations of each attribute of the target object in turn; For each attribute of the target object, based on the identifier in the annotation corresponding to the attribute, the identifier payload mapping table is used to obtain the payload of the attribute, the payload is deserialized to obtain the value of the attribute, and the reflection mechanism is used to assign a value to the attribute, including: determining the attribute type of the attribute; if the attribute type is a simple attribute, the payload is directly deserialized to obtain the value of the simple attribute, and the reflection mechanism is used to assign a value to the attribute; if the attribute type is a complex attribute, the local deserialization converter corresponding to the attribute is called, the payload is deserialized to obtain the value of the attribute, and the reflection mechanism is used to assign a value to the attribute; the simple attribute is an attribute defined based on a basic data type, and the complex attribute is an attribute defined based on a custom object; the payload is the first serialized data obtained by converting the attribute of the target object; Output the target object after each attribute is assigned a value; Calling the local deserialization converter corresponding to the attribute, deserializing the payload to obtain the value of the attribute, and assigning the value to the attribute using the reflection mechanism, including: taking the payload as the target serialization data, the local deserialization converter executing the steps from obtaining the target serialization data to outputting the target object after each attribute is assigned a value, taking the target object as the value of the attribute, and assigning the value to the attribute using the reflection mechanism.
3. A data processing device, characterized in that: include: A target object acquisition module, used to acquire the target object; An attribute annotation acquisition module is used to sequentially acquire the annotation of each attribute of the target object by using a reflection mechanism; the annotation includes serialization parameters of its corresponding attribute; the serialization parameters are used to indicate the serialization rules of the global data converter or the local data converter; A first serialization module, configured to convert each attribute of the target object into first serialized data based on an indication parameter of an annotation corresponding to the attribute; The first serialization module includes: an attribute type determination module, which is used to determine the attribute type of the attribute; a simple attribute serialization module, which is used to directly convert the simple attribute into the first serialized data according to the serialization parameters in the annotation if the attribute type is a simple attribute; a complex attribute serialization module, which is used to call the serialization converter corresponding to the attribute in the annotation to convert the attribute into the first serialized data if the attribute type is a complex attribute; the simple attribute is an attribute defined based on a basic data type, and the complex attribute is an attribute defined based on a custom object; A second serialization module, used for generating second serialization data of the target object based on the first serialization data of each attribute; The complex attribute serialization module includes: a complex attribute nested processing module, which is used to take the complex attribute as the target object, call the serialization converter in the device to implement the data processing, a module from obtaining the target object to generating the second serialization data of the target object, take the second serialization data as the first serialization data, and the serialization converter outputs the first serialization data.
4. A data processing device, characterized in that: include: A serialized data acquisition module is used to acquire target serialized data; An identification payload list generation module, used for parsing the target serialized data and generating an identification payload mapping table; the identification payload mapping table contains the corresponding relationship between the identification of each attribute of the target object and the first serialized data of the attribute; The target object is the object corresponding to the target serialized data; The attribute annotation acquisition module is used to construct the target object by using the reflection mechanism, and sequentially obtain the annotations of each attribute of the target object; An attribute assignment module, for obtaining a payload of each attribute of a target object based on an identifier in an annotation corresponding to the attribute, using the identifier payload mapping table, deserializing the payload to obtain a value of the attribute, and assigning a value to the attribute using a reflection mechanism; The payload is first serialized data obtained by converting the attributes of the target object; The attribute assignment module includes: an attribute type module, which is used to determine the attribute type of the attribute; a simple attribute deserialization module, which is used to directly deserialize the payload to obtain the value of the simple attribute if the attribute type is a simple attribute, and use the reflection mechanism to assign a value to the attribute; a complex attribute deserialization module, which is used to call the deserialization converter corresponding to the attribute if the attribute type is a complex attribute, deserialize the payload to obtain the value of the attribute, and use the reflection mechanism to assign a value to the attribute; the simple attribute is an attribute defined based on a basic data type, and the complex attribute is an attribute defined based on a custom object; A target object output module, used for outputting the target object after each attribute is assigned a value; The complex attribute deserialization module includes: taking the payload as the target serialized data, the deserialization converter implementing the data processing device, the steps from obtaining the target serialized data to outputting the target object after each attribute is assigned a value, taking the target object as the value of the attribute, and using the reflection mechanism to assign a value to the attribute.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that: When the processor executes the computer program, the method according to claim 1 or 2 is implemented.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to claim 1 or 2 is implemented.
