CN105793842B - Conversion method and device between serialized message - Google Patents

Conversion method and device between serialized message Download PDF

Info

Publication number
CN105793842B
CN105793842B CN201380081227.7A CN201380081227A CN105793842B CN 105793842 B CN105793842 B CN 105793842B CN 201380081227 A CN201380081227 A CN 201380081227A CN 105793842 B CN105793842 B CN 105793842B
Authority
CN
China
Prior art keywords
data
item
serialized
data structure
xml
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201380081227.7A
Other languages
Chinese (zh)
Other versions
CN105793842A (en
Inventor
吕明伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Feinno Communication Technology Co Ltd
Original Assignee
Beijing Feinno Communication Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Feinno Communication Technology Co Ltd filed Critical Beijing Feinno Communication Technology Co Ltd
Publication of CN105793842A publication Critical patent/CN105793842A/en
Application granted granted Critical
Publication of CN105793842B publication Critical patent/CN105793842B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Abstract

The invention discloses the conversion methods and device between a kind of serialized message.Method provided in an embodiment of the present invention includes: to describe item formation sequence data structure using the serializing of setting according to the corresponding relationship between the first structure and first structure of First ray message and the second structure of the second serialized message;Wherein, serializing description item includes that data structure describes item and data structure is arranged in describe field description item among item;Serialized message to be converted to the first format for meeting first structure, treats conversion sequence message according to serialized data structure and is parsed, and the data parsed are written in serialized data structure, the serialized data structure after obtaining data write-in;The data in serialized data structure after extracting data write-in;According to the corresponding relationship recorded in serialized data structure, the data extracted are converted to the serialized message of the second format with the second structure.

Description

Conversion method and device between serialized message
Technical field
Conversion method and dress the present invention relates to technical field of data processing, in particular between a kind of serialized message It sets.
Background technique
With the development of internet and the application of cloud computing, large-scale distributed system is more and more, message sequence It is a ring important in distributed system, it is responsible for the message transmission between service cluster as blood.In message sequence In common serializing agreement include self-explanatory serializing agreement such as XML (Extensible Markup Language, extension Property identifiable language) agreement, be based on binary serializing agreement ProtocolBuffer (protocol cache, referred to as PB) and JSON (JavaScript Object Notation, JavaScript object label) agreement etc..
Currently, a kind of server generally only supports a kind of serializing agreement of format, as WEB (webpage) server is only supported The agreement of XML format or JSON format, and service server generally only supports the agreement of PB format.
Existing scheme at least has the drawback that
Since existing server is generally only capable of supporting the message of single format, the message transmission side between server is limited Formula is such as only capable of transmitting message according to XML format or be only capable of according to PB format transmission message, and the message body of XML format message It is larger, operational efficiency is poor, the message readability of PB format is poor.The mode of the message transmission of server is ineffective in existing scheme Work, message transmission performance are low.
Summary of the invention
In view of the above problems, the embodiment of the invention provides the conversion methods and corresponding sequence between a kind of serialized message Conversion equipment between columnization message, to solve in existing scheme, not flexible, message is passed in a manner of message transmission between server The problem of defeated degraded performance etc..
In order to achieve the above object, technical solution used in the embodiment of the present invention is as follows:
On the one hand, the embodiment of the invention provides the conversion methods between a kind of serialized message, comprising:
According to First ray message first structure and first structure and the second serialized message the second structure it Between corresponding relationship, item formation sequence data structure is described using the serializing of setting;Wherein, First ray message has First format, the second serialized message have the second format;Serializing description item includes that data structure describes item and is arranged in number The field description item among item is described according to structure, each data structure describes the structure of item and data structure describes each field among item The structure for describing item is consistent with first structure;Serialized message to be converted to the first format for meeting first structure, according to Serialized data structure is treated conversion sequence message and is parsed, and the data parsed are written in serialized data structure, Serialized data structure after obtaining data write-in;The data in serialized data structure after extracting data write-in;According to sequence The data extracted are converted to the sequence of the second format with the second structure by the corresponding relationship recorded in columnization data structure Change message.
On the other hand, the embodiment of the invention provides the conversion equipments between a kind of serialized message, comprising:
Data structure building unit, for the first structure and first structure and the second sequence according to First ray message Corresponding relationship between second structure of columnization message describes item formation sequence data structure using the serializing of setting;Its In, First ray message has the first format, and the second serialized message has the second format;Serializing description item includes data Structure describes item and data structure is arranged in describe field description item among item, and each data structure describes the structure and data of item The structure that structure describes each field description item among item is consistent with first structure;
Writing unit is parsed, for the serialized message to be converted to the first format for meeting first structure, according to sequence Change data structure is treated conversion sequence message and is parsed, and the data parsed are written in serialized data structure, are obtained Serialized data structure after data write-in;
Data extracting unit, for extracting the data in the serialized data structure after data are written;
Converting unit, for according to the corresponding relationship recorded in serialized data structure, the data extracted to be converted to The serialized message of the second format with the second structure.
From the above mentioned, the embodiment of the present invention uses and by the serializing being arranged describes item formation sequence data structure, by the Serialized data structure is written in the serialized message to be converted of one format, then will from the serialized data structure after data write-in Data extract the technological means for being converted to the serialized message of the second format, can pass through a kind of serialized data structure compatible The serialized message of multiple format enables the server to carry out the serialized message of different-format conversion easily and fast, root The serializing agreement of specific format is chosen to transmit serialized message according to actual demand, for example, using XML lattice outside server Formula transmits message, to inherit the popularity that XML format is applied in systems, uses PB format transmission message in server internal, To inherit the high efficiency of PB format, to improve the flexibility of server transmitting message, message transmission performance is optimized.
Detailed description of the invention
Fig. 1 shows the conversion method flow chart between a kind of serialized message according to an embodiment of the invention;
Fig. 2 shows another embodiment according to the present invention according to serialized data structure to XML serialization message into The method schematic diagram of row parsing;
Fig. 3 shows output PB sequence in the serialized data structure of the slave data write-in of another embodiment according to the present invention The flow chart of columnization message;
Fig. 4 shows being parsed according to serialized data structure to PB message for another embodiment according to the present invention Method schematic diagram;
XML is exported in the serialized data structure that the slave data that Fig. 5 shows another embodiment according to the present invention are written The flow chart of serialized message;
The structure that Fig. 6 shows the conversion equipment between a kind of serialized message of another embodiment according to the present invention is shown It is intended to.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with attached drawing to embodiment party of the present invention Formula is described in further detail.
One embodiment of the invention provides the conversion method between a kind of serialized message, and referring to Fig. 1, this method includes Following steps:
S100: according to the first structure of First ray message and the first structure and the second of the second serialized message Corresponding relationship between structure describes item formation sequence data structure using the serializing of setting, wherein the First ray Message has the first format, which has the second format.
Above-mentioned first format, the second format respectively correspond a kind of data format for serializing agreement, such as XML (Extensible Markup Language, scalability identifiable language) format, PB (protocol cache, referred to as PB) format or JSON (JavaScript Object Notation, JavaScript object label) format etc., wherein the first format is different In the second format.
Serialized data structure is the bridge of mutual inversion of phases between serialized message, and it includes several serializing descriptions ?.One serializing description item represents the type or field that one can be serialized, for describing rule when serializing.
Serializing description item includes that data structure describes item and field description item.It is a series of fields that data structure, which describes item, The set of item is described, a data structure describes to may include multiple field description items in item, and data structure describes same in item Can nested another data structure, i.e., describe sub-data structure is arranged in item in data structure and describe item, to support complexity Data type.
Sub-data structure describes item and describes that item is essentially identical, and the main distinction is that sub-data structure describes item with data structure In also need to include a kind of relation information, by this relation information establish be located at same data structure the subdata knot in item is described Structure describes the relationship of item Yu field description item.
Each data structure describes the structure of item and data structure describes each field description item, subdata among item and describes item The structure of (when if it exists) needs consistent with first structure.It is illustrated below with reference to example.
Illustratively, when the first format is XML format, the First ray message (XML serialization with first structure Message) an example it is as follows:
In the first structure of above-mentioned XML serialization message, root node name is " config ", includes entitled in root node " name " and " address " node elements, further include a nested minor structure in the first structure, the sub- root node in minor structure Entitled " childs ", nodal community in sub- root node including entitled " childName " and entitled The node elements of " childAddress ".
When the second format is PB format, one of the second serialized message (PB serialized message) with the second structure Example is as follows:
In second structure of above-mentioned PB serialized message, including serial number 1, the number that data type is character string (string) According to item and serial number 2, the data item that data type is character string.It further include the nesting of a serial number 3 in above-mentioned second structure It is character that minor structure, which includes serial number 1, the data item that data type is character string and serial number 2, data type in the minor structure, The data item of string.
Then according to the first structure of XML serialization message and the first structure and the second structure of PB serialized message it Between corresponding relationship, describe item formation sequence data structure using the serializing of setting, can be expressed as follows:
It include that a data structure describes item in above-mentioned serialized data structure, which describes to include structure in item Title, field description item and sub-data structure describe item.Root node name " config " in the entitled above-mentioned first structure of structure.
Field description item includes data type (type), serial number, node type and title, and wherein node type is default It can be omitted when node type (such as node elements).Serial number in field description item corresponds to the serial number in PB format, and field is retouched State serial number of the data in the PB serialized message with the second structure in the serial number field description item in item, such as field When describing in item including " serial number=1 ", indicate that the data in the field description item correspond to the data of serial number 1 in PB format ?;Node type in node type field description item includes node elements and nodal community, and the node type of default is node Element can be omitted and not write;Title in field description item corresponds to the title of XML format interior joint element or nodal community.
It includes that serial number, minor structure title and subfield describe item that sub-data structure, which describes item,.Subnumber is utilized in above-mentioned example It describes the serial number (serial number=3) in item according to structure and establishes the sub-data structure to describe field in item and same serialized data structure Relationship between item is described, sort in the data structure of above-mentioned example it is primary be serial number 1 field description item, sequence the Two be serial number 2 field description item, then can know that the sub-data structure of serial number 3 describes item and the first two field The relationship for describing item is after the sequence of the first two field description item.Sub-data structure describes the minor structure title pair in item It should be in the title of XML format neutron root node.Subfield describes to include data type, serial number, node type and title, son in item The effect of every terms of information is identical as the effect of every terms of information in field description item in field description item.
From the foregoing, it will be observed that describing structure title, sub-data structure in item by data structure describes minor structure name in item Title and field description item and subfield describe first structure and PB that serial number, title in item establish XML serialization message Corresponding relationship between second structure of serialized message;For the scene of nested structure is not present, described by data structure Structure title in and serial number, title in field description item establish the first structure of XML serialization message and PB is serialized Corresponding relationship between second structure of message;Information in information and field description item in item is described by data structure By correspondence setting in serialized data structure.In a kind of mode of texturing, it can also only pass through the letter in field description item Breath is by correspondence setting in serialized data structure.
Above-mentioned data structure describes item, sub-data structure describes item, field description item and subfield describe the information in item It is different according to the format of serialized message and structure and change, herein without considered critical.
By aforesaid operations, after the completion of serialized data Structure Creating, S101 is entered step.
S101: the serialized message to be converted to the first format for meeting first structure, according to serialized data structure pair The serialized message to be converted is parsed, and the data parsed are written in the serialized data structure, obtains data write-in Serialized data structure afterwards.
For example, can describe to increase a numerical value in item in field description item or subfield when data are written (value), the data parsed are written in value.
S102: the data in serialized data structure after extracting data write-in.
S103: according to the corresponding relationship recorded in serialized data structure, the data extracted are converted to second The serialized message of second format of structure.
For the present invention scene that another embodiment is XML format in the first format, the second format is PB format, to upper The operation stated in step S101 is illustrated, and wherein the serialized message of XML format has first structure, the serializing of PB format Message has the second structure;To the other content of the conversion method between serialized message referring to the other embodiment of the present invention.
After S100 through the above steps gets serialized data structure, meet all XML serializations of first structure Message all can serve as serialized message to be converted and be parsed using the serialized data structure, and resolving referring to fig. 2, is shown The process parsed according to serialized data structure to XML serialization message is gone out, has included the following steps:
S200: server (or other equipment) loads XML serialization message to be converted.
S201: server is according to the XML serialization message correction root node to be converted.
Server uses streaming analytic method, according to serialized data structure to the XML in XML serialization message to be converted Element is read out, and is handled one by one the XML element in the XML serialization message to be converted read out.When reading out XML element in title and data structure describe the structure title in item it is identical when, determine the corresponding XML section of the XML element Point is root node.
Keep the node of XML consistent with field description item corresponding in serialized data structure by correcting root node.
S202: server parses the nodal community in present node, and the data as the XML element of nodal community are written In serialized data structure in corresponding field description item, S203 is entered step.
Present node is the subordinate being presently processing or is subordinated to the XML node of root node indirectly, in present node XML element subordinate is subordinated to root node indirectly.The data of XML element in present node are parsed one by one, will be parsed Data be written serialized data structure.When the title in the XML element is identical as the title in field description item and XML member When the type of element is identical as the node type in field description item, the data of the XML element parsed are written in the field It describes in item.
The type of XML element includes nodal community and node elements, and the present embodiment is first carried out when executing parsing to current The parsing of nodal community in the present node of processing, then the parsing to node elements is executed, however, the present embodiment is not to section The parsing sequence of point attribute and node elements carries out considered critical.
For example, to the following field description item recorded in serialized data structure:
Field { serial number=1, title=" childName ", node type=" attribute ", type=String } will parse Nodal community data the field description item is written after, it is specific as follows:
Field { serial number=1, title=" childName ", node type=" attribute ", type=String, value= “XXX”}
Wherein, the XXX being written in above-mentioned value indicates the data of the XML element as nodal community parsed.
S203: server parses the node elements in present node, enters step S204.
Read out the title of the XML element in currently processed XML node and the data of XML element.
S204: server judges whether there is nested structure, if so, return step S201, if it is not, entering step S205.
Nested structure is judged whether there is according to the title of the XML element, when the title and subnumber of the XML element read out According to structure describe the minor structure title in item it is identical when, confirmation there are nested structures.
Wherein, for above-mentioned there are the scene of nested structure, after return step S201, currently processed XML element is made For sub- root node (replacing root node with the sub- root node), each XML element in sub- root node, the XML in group root node are read The title of element and subfield describe that the title in item (describing item replacement field description item with subfield) is identical and the XML element Type and subfield describe the node type in item it is identical when, the data of the XML element parsed are written in the sub- word In segment description item.
S205: the data as the XML element of node elements are written in corresponding field descriptor server, into step Rapid S206.
The title of the XML element read out is identical as the title in field descriptor, and the section in the field descriptor When vertex type is node elements, the corresponding node elements of the XML element are confirmed, read out the data write-in pair of the XML element In the field descriptor answered.
S206: judge whether the data of the XML element in the XML serialization message to be converted read out all have been written into Item is described to corresponding field description item or subfield, if so, S207 is entered step, if it is not, return step S201, repeats The XML element not being written is written field description item or subfield describes in item by above-mentioned steps S201 to S206, until judging All data in XML serialization message are all written in serializing structure, enter step S207.
S207: by after the data of write-in XML element field description item or subfield describe item obtain data write-in after Serialized data structure, end operation.
For the present invention scene that another embodiment is XML format in the first format, the second format is PB format, mainly To extracting data in the serializing structure after being written from data and be converted to the behaviour of the PB serialized message with the second structure It is illustrated.To the other content of the conversion method between serialized message referring to the other embodiment of the present invention.
After in the data write-in serialized data structure that will be stored in XML serialization message, needing will be in data structure Data with PB format output, be finally completed the conversion of the serialized message from the serialized message of XML format to PB format, Execute the protocol specification that PB is followed when conversion.Serializing number referring to Fig. 3, after showing the write-in provided in this embodiment from data According to the flow chart for exporting PB serialized message in structure, specifically comprise the following steps:
S300: server (or other equipment) starts the output of PB serialized message, enters step S301.
Server enters the output mode of PB format, and under the output mode, server exports PB serialized message.Service Serialized data structure after device load data write-in is to execute format conversion.
S301: server extracts data and son in field description item from the serialized data structure after data write-in Data structure describes the data in item (if there is when), enters step S302.
S302: server executes different operation according to the different type of the data extracted.
When the data extracted are the data of value type, S303 is entered step;
When the data extracted are the data of character string type, S304 is entered step;
When the data extracted are that sub-data structure describes item, S305 is entered step.
S303: when the data extracted are the data of value type, following first methods are used to be handled: with variable (Varint) mode is first by the serial number of the data recorded in field description item and phase in data type write-in PB serialized message With serial number in corresponding data item, then the data of value type are written in the data item.
S304: when the data extracted are the data of character string type, following second methods is used to be handled: with Varint mode is first identical with data type write-in PB serialized message by the serial number of the data recorded in field description item In the corresponding data item of serial number, then the string length of the data recorded in field description item is written in the data item, so The data of character string type are written in the data item afterwards.
S305: when the data extracted are that sub-data structure describes item, first by the sub-data structure in a manner of Varint Same sequence number in serial number and structure type (structure type indicates sub-data structure) write-in PB serialized message in item is described In corresponding data item, then the sub-data structure is described into data length in item and is written in the data item, then return step S301 is distinguished using into S304, identical method subdata structure describes the data in item and handled with step S301 The field description item that point essentially consists in by step S301 into S304 replaces with subfield and describes item, i.e., the content that ought be extracted is When the data of value type, according to above-mentioned first method, the data recorded in item first are described into subfield in a manner of Varint Serial number and data type write-in PB serialized message in the corresponding data item of same sequence number, then the data of value type are write Enter in the data item;When the data extracted are the data of character string type, according to above-mentioned second method, in a manner of Varint The serial number that subfield is first described to the data recorded in item is corresponding with same sequence number in data type write-in PB serialized message Data item in, then the string length for the data that subfield describes to record in item is written in the data item, then by word The data of symbol string type are written in the data item.
S306: judging whether the data extracted all have been written into PB serialized message in corresponding data item, if so, S307 is entered step, if it is not, return step S302, repeats above-mentioned steps S302 to S306, according to the data not being written The data not being written are written in corresponding data item using first method or second method for data type, until to serializing All data processings in data structure finish,
S307: the PB serialized message with the second structure is obtained by each data item after write-in data.
So far, it completes from XML serialization message to the conversion of PB serialized message, end operation.
For the present invention scene that another embodiment is PB format in the first format, the second format is XML format, mainly To the data in the serialized message of the PB format of parsing first structure, by the data parsed write-in serialized data structure Operation is illustrated.The other content of conversion method between serialized message is referring to the other embodiment of the present invention.
After getting serialized data structure, all PB serialized messages for meeting first structure can use the sequence Columnization data structure is parsed, resolving referring to fig. 4, show according to serialized data structure to PB serialized message into The process of row parsing, includes the following steps:
S400: the binary data stream of server load PB serialized message to be converted.
S401: server reads the variable (Varint) in the binary data stream of PB serialized message to be converted one by one Value.
S402: server executes different operation according to the different type of the Varint value extracted.
Server can judge the data of data extracted according to the corresponding relationship recorded in serialized data structure first Type, for example, server is according to the data type in field description item you can learn that the data that are written in the field description item Data type.When specific operation, server obtains the corresponding data type of the variate-value and serial number from the variate-value read. According to Varint coding standard, 3 bits place data type after the binary data of Varint value, and remaining bit is placed Serial number.
When the Varint value read out is value type, S403 is entered step;
When the Varint value read out is character string type, S404 is entered step;
When the Varint value read out is that sub-data structure describes item, S405 is entered step.
Here, determining to read when the serial number of the Varint value read out is identical as the serial number that sub-data structure describes item Varint value out is that sub-data structure describes item.
S403: it when the Varint value read out is value type, is handled using following Third Way: continuing to read Next Varint value (data that next Varint value is value type), by next Varint value write-in serializing In data structure in serial number field description item identical with the serial number of the Varint value.Due to being had recorded in serialized data structure The serial number and data type of data item in PB format, and in serialized data structure each data item sequence also with it is to be converted The sequence of each data item is identical in PB serialized message, thus can be by each number in PB serialized message according to serializing structure It quickly reads out according to item, the data read out is written in serialized data structure according to data type and serial number.
S404: it when the Varint value read out is character string type, is handled using following fourth way: after resuming studies Next Varint value is taken, string length is obtained, then reads the byte of string length size again, to the byte read UTF8 (8-bit Unicode Transformation Format) coding is carried out, character string is obtained, which is written into sequence In columnization data structure in serial number field description item identical with the serial number of the character string.
S405: when the serial number of the Varint value read out is identical as the serial number that sub-data structure describes item, continue to read Next Varint value, obtains data length, and the byte for then reading data length size again obtains bytecode set, returns to step Rapid S401.Using into S404, identical method subdata structure describes the data in item and is handled with step S401, area The field description item that other point essentially consists in by step S401 into S404 replaces with subfield and describes item, i.e., when from the byte code collection The Varint value read out in conjunction be value type when, handled using above-mentioned Third Way, using following Third Way into Row processing: continuing to read next Varint value, by serial number in next Varint value write-in serialized data structure and is somebody's turn to do The identical subfield of the serial number of Varint value describes in item.When the Varint value read out from the bytecode set is character string It when type, is handled using above-mentioned fourth way: continuing to read next Varint value, obtain string length, then again The byte for reading string length size carries out UTF8 coding to the byte read, obtains character string, which is written Serial number subfield identical with the serial number of the character string describes in item in serialized data structure.
S406: judge all Varint values in PB serialized message to be converted whether all have been written into field description item or Subfield describes in item, if so, S407 is entered step, if it is not, return step S402, repeats above-mentioned steps S402 extremely S406 is write the variate-value not being written using Third Way or fourth way according to the data type for the Varint value not being written Enter field description item or subfield describes in item, until all data in PB serialized message are all written in serializing structure, Enter step S407.
S407: by write-in Varint value after field description item or subfield describe item obtain data write-in after serializing Data structure.End operation.
For the present invention another embodiment is PB format in the first format, the second format is XML format scene, to pressing According to the corresponding relationship in serialized data structure, the data extracted are converted to the behaviour of the XML serialization message of the second structure It is illustrated.The other content of conversion method between serialized message is referring to the other embodiment of the present invention.
After in the data write-in serialized data structure that will be stored in PB serialized message, needing will be in data structure Data export in xml format, are finally completed the conversion from PB format to XML format, referring to Fig. 5, show the present embodiment provides Slave data write-in after serialized data structure in export XML serialization message flow chart, specifically comprise the following steps:
S500: server (or other equipment) starts the output of XML serialization message, enters step S501.
Server enters the output mode of XML format, and under the output mode, server exports XML serialization message.Clothes Serialized data structure after business device load data write-in is to execute format conversion.
S501: server creates XML root node, enters step S502.
Server first can according to the corresponding relationship recorded in serialized data structure, judge the data extracted whether be The node type for the data that structure title and judgement extract.When the title and serialized data structure in the data extracted When the structure title of record is identical, with the data and structure title, the root node in XML serialization message is created.
S502: server extracts data and son in field description item from the serialized data structure after data write-in Data structure describes item (if there is when), enters step S503.
S503: server creates XML node attribute, writes data into the XML node attribute, enters step S504.
It describes the node type recorded in item by field description item belonging to the data that extract or subfield and can obtain Know that the data correspond to node elements or nodal community.
It when the data extracted are nodal community, is handled using following 6th modes: at present node (current place Reason the node for being depending directly or indirectly on root node) under in the field description item of nodal community title create XML node Attribute, and the data in field description item are written in the XML node attribute.
The present embodiment first creates the nodal community in XML serialization message when executing conversion, then creates node elements, However, the present embodiment does not carry out considered critical to the creation sequence of nodal community and node elements.
S504: server creates XML node element.
When the data extracted be node elements when, to do not have nested structure scene, using following 5th modes into Row processing: XML node is created with the title in the field description item of node elements under root node, and by field description item or son Data in field description item are written in the XML node.
To the scene with nested structure, in this step with the name in the field description item of node elements under root node After claiming creation XML node element, S505 is entered step.
S505: server judges whether node is nested structure, if so, return step S502, if it is not, entering step S506.Know that the data correspond to sub-data structure and describe item when in the data extracted including minor structure title.
When the data extracted are that sub-data structure describes item, i.e., when node includes nested structure, with the subdata knot Structure describes the title in item and creates sub- root node, extracts sub-data structure and describes the data in item, using with step S502 extremely Identical method subdata structure describes the data in item and is handled in S504, and distinctive points are essentially consisted in step S501 extremely Field description item in S504 replaces with subfield and describes item, i.e., when the data extracted are node elements, in sub- root node Under with the subfield of node elements describe the title in item creation XML node, and by subfield describe the data in item write-in should In XML node.When the data extracted are nodal community, described in item under present node with the subfield of nodal community Title creates XML node attribute, and subfield is described the data in item and is written in the XML node attribute.
S506: the data in field description item (or subfield description item) are written in the XML node server.
S507: judge whether the data extracted all have been written into corresponding XML node element or XML node attribute In, if so, enter step S508, if it is not, return step S502, repeats above-mentioned steps S502 to S507, according to not being written Data node type, the data not being written are written by corresponding XML node member using above-mentioned 5th mode or the 6th mode In element or XML node attribute, until being finished to all data processings in the serialized data structure after data write-in, into step Rapid S508.
S508: XML node element or XML node attribute after being written by data obtain the XML sequence with the second structure Change message, end operation.
Another of the invention embodiment provides the conversion equipment 600 between a kind of serialized message.Referring to Fig. 6, the dress Setting 600 includes data structure building unit 601, parsing writing unit 602, data extracting unit 603 and converting unit 604.Number It include correspondence setting unit 6011 and minor structure setting unit 6012 according to structural generation unit 601.
Data structure building unit 601 is used for first structure and first structure and second according to First ray message Corresponding relationship between second structure of serialized message describes item formation sequence data structure using the serializing of setting; Wherein, First ray message has the first format, and the second serialized message has the second format;Serializing description item includes number It describes item according to structure and data structure is arranged in describe field description item among item, each data structure describes the structure and number of item The structure for describing each field description item among item according to structure is consistent with first structure.Specifically, data structure building unit 601 Including correspondence setting unit 6011, for the first structure and first structure and the second sequence according to First ray message Corresponding relationship between second structure of columnization message describes information and word in item using the data structure of serializing description item Information in segment description item is by correspondence setting in the serialized data structure of generation.First format be XML format, second When format is PB format, alternatively, the first format is PB format, when the second format is XML format, correspondence setting unit 6011, for describing setting structure title and field description item in item in data structure, the structure is entitled to have first structure XML serialization message in root node title, include data type, serial number, node type and title in the field description item, Serial number of the data in the PB serialized message with the second structure in serial number field description item;It is described by data structure In structure title, the serial number in field description item and title by correspondence setting generation serialized data structure In.
Data structure building unit 601 further includes minor structure setting unit 6012, for describing Xiang Zhongshe in data structure It sets sub-data structure and describes item, wherein sub-data structure describes to be provided with subfield in item and describes item, and corresponding relationship includes being located at Same data structure describes the relationship that the sub-data structure in item describes item Yu field description item.Then correspondence setting unit 6011, item, structure title are described for describing setting structure title in item, field description item and sub-data structure in data structure For the title of root node in the XML serialization message with first structure, sub-data structure describes to include serial number, minor structure in item Title and subfield describe item, and field description item or subfield describe to include data type, serial number, node type and name in item Claim, serial number field description item or subfield describe sequence of the data in item in the PB serialized message with the second structure Number;By data structure describe structure title, sub-data structure in item describe minor structure title in item, field description item and Subfield describes serial number in item and title for correspondence setting in the serialized data structure of generation.
When the first format is XML format, and the second format is PB format, parsing writing unit 602 is used for according to serializing Data structure is read out the XML element in XML serialization message to be converted, the title in the XML element read out With data structure describe the structure title in item it is identical when, determine the corresponding XML node of XML element be root node;Read subordinate Or be subordinated to each XML element of root node indirectly, when the title in XML element with the title in field description item identical and XML When the type of element is identical as the node type in field description item, the data of the XML element parsed are written in field and are retouched It states in item;When title and the sub-data structure in XML element describe the minor structure title in item it is identical when, using XML element as Sub- root node reads subordinate or is subordinated to each XML element of sub- root node indirectly, is subordinated to sub- root node when subordinate or indirectly The title of XML element and subfield describe that the title in item is identical and the type and subfield of XML element describe the node in item When type is identical, the data of the XML element parsed are written in subfield and are described in item;Judgement is read out to be converted Whether the data of the XML element in XML serialization message, which all have been written into corresponding field description item or subfield, describes item, If so, by after the data of write-in XML element field description item or subfield describe item obtain data write-in after serializing number According to structure, if it is not, the XML element not being written write-in field description item or subfield are described in item, the field description item or son The title and node type of field description item are identical as the title of XML element and type that are not written.
Converting unit 604, for judging the data extracted according to the corresponding relationship recorded in serialized data structure Data type;When the data extracted are the data of value type, following first methods are used to be handled: in a manner of variable The serial number and phase in data type write-in PB serialized message that field description item or subfield are first described to the data recorded in item With serial number in corresponding data item, then will be in the data write-in data item of value type;When the data extracted are character string class When the data of type, following second methods is used to be handled: first being described field description item or subfield in item in a manner of variable In the serial number of the data of record and data type write-in PB serialized message in the corresponding data item of same sequence number, then field retouched It states item or subfield describes in the string length write-in data item of the data recorded in item, then by the data of character string type It is written in data item;When the data extracted are that sub-data structure describes item, first sub-data structure is described in a manner of variable Serial number and structure type in are written in PB serialized message in the corresponding data item of same sequence number, then sub-data structure is retouched It states in item in data length write-in data item, the subfield that then extraction sub-data structure describes item describes the data in item, when It when the data extracted are the data of value type, is handled using first method, when the data extracted are character string class When the data of type, handled using second method;Judge whether the data extracted all have been written into PB serialized message In corresponding data item, if so, obtaining the serializing of the second format with the second structure by each data item after write-in data Message, if it is not, using first method or second method, the data not being written are write according to the data type for the data not being written Enter in corresponding data item.
When the first format is PB format, and the second format is XML format, writing unit 602 is parsed, for reading PB one by one Variate-value in the binary data stream of serialized message to be converted;The corresponding number of variate-value is obtained from the variate-value read According to type and serial number;When the variate-value read out is value type, is handled: being continued under reading using following Third Way Serial number field description identical with the serial number of variate-value in serialized data structure is written in next variate-value by one variate-value Item or subfield describe in item, when the variate-value read out is character string type, are handled using following fourth way: after It resumes studies and takes next variate-value, obtain string length, then read the byte of string length size again, obtain character string, Serial number field description item identical with the serial number of character string or subfield in serialized data structure is written into character string and describes item In;When the serial number of the variate-value read out is identical as the serial number that sub-data structure describes item, continue to read next variate-value, Data length is obtained, the byte for then reading data length size again obtains bytecode set, and, it reads in bytecode set Variate-value, when the variate-value read out be value type when, handled using Third Way, when the variate-value read out is When character string type, handled using fourth way;Judge all variate-values in PB serialized message to be converted whether all Have been written into field description item or subfield describe in item, if so, by after write-in variate-value field description item or subfield retouch It states item and obtains the serialized data structure after data write-in, if it is not, according to the data type for the variate-value not being written, using third Mode or fourth way describe the variate-value not being written write-in field description item or subfield in item.
Converting unit 604, for judging that the data extracted are according to the corresponding relationship recorded in serialized data structure No is structure title and the node type for judging the data extracted;When the data extracted include that structure name claims, with this Root node in data and structure title creation XML serialization message;When the data extracted are node elements, use is following 5th mode is handled: field description item or subfield under root node with node elements describe the creation of the title in item XML node element, and field description item or subfield are described in the write-in XML node element of the data in item;When what is extracted When data are nodal community, following 6th modes are used to be handled: with the field description item of nodal community under present node Or subfield describes the creation XML node attribute of the title in item, and field description item or subfield are described the data in item and write Enter in XML node attribute;When the data extracted are that sub-data structure describes item, the title in item is described with sub-data structure Sub- root node is created, sub-data structure is extracted and describes the data in item, when the data extracted are node elements, in sub- root section Point is lower to be handled using the 5th mode, when the data extracted are nodal community, is handled using the 6th mode;Judgement Whether the data extracted all have been written into corresponding XML node element or XML node attribute, if so, being written by data XML node element or XML node attribute afterwards obtains the serialized message of the second format with the second structure, if it is not, according to Using above-mentioned 5th mode or the 6th mode corresponding XML is written in the data not being written by the node type for the data not being written In node elements or XML node attribute.
Data extracting unit 603 is used to extract the data in the serialized data structure after data write-in.
The specific working mode of each unit may refer to embodiment of the method for the invention in apparatus of the present invention embodiment.
From the above mentioned, the embodiment of the present invention uses and by the serializing being arranged describes item formation sequence data structure, by the The serialized data structure is written in the serialized message to be converted of one format, then from the serialized data structure after data write-in Data are extracted to the technological means for being converted to the serialized message of the second format, it can be simultaneous by a kind of serialized data structure The serialized message for holding multiple format enables the server to carry out the serialized message of different-format conversion easily and fast, The serializing agreement of specific format is chosen according to actual needs to transmit message, for example, passing outside server using XML format Defeated message, to inherit the popularity that XML format is applied in systems, server internal use PB format transmission message, with after The high efficiency of PB format is held, to improve the flexibility of server transmitting message, optimizes message transmission performance.
For the ease of clearly describing the technical solution of the embodiment of the present invention, in the embodiment of invention, use " first ", Printed words such as " second " distinguish function and the essentially identical identical entry of effect or similar item, and those skilled in the art can manage The printed words such as solution " first ", " second " are not defined quantity and execution order.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all Any modification, equivalent replacement, improvement and so within the spirit and principles in the present invention, are all contained in protection scope of the present invention It is interior.

Claims (14)

1. the conversion method between a kind of serialized message, comprising:
According to the first structure of First ray message and the first structure and the second structure of the second serialized message it Between corresponding relationship, item formation sequence data structure is described using the serializing of setting;Wherein, First ray message has First format, the second serialized message have the second format, and the first format, the second format respectively correspond a kind of serializing agreement Data format;Serializing description item includes that data structure describes item and the field that data structure describes among item is arranged in retouch State item, each data structure describes the structure of item and data structure describes among item the structure of each field description item and described the One structure is consistent;
Serialized message to be converted to the first format for meeting the first structure, according to the serialized data structure to institute It states serialized message to be converted to be parsed, the data parsed is written in the serialized data structure, data is obtained and writes Serialized data structure after entering;
The data in serialized data structure after extracting the data write-in;
According to the corresponding relationship recorded in the serialized data structure, the data extracted are converted to the second knot The serialized message of second format of structure;
First format is XML format, when second format is PB format,
The serialized message to be converted of described pair of the first format for meeting the first structure, according to the serialized data structure The serialized message to be converted is parsed, the data parsed are written in the serialized data structure, are counted Include: according to the serialized data structure after write-in
The XML element in XML serialization message to be converted is read out according to the serialized data structure, when reading out XML element in title and data structure describe the structure title in item it is identical when, determine the corresponding XML of the XML element Node is root node;
It reads subordinate or is subordinated to each XML element of root node indirectly, when in the title and field description item in the XML element When title is identical and the type of the XML element is identical as the node type in field description item, the XML that will parse The data of element are written in the field description item;When the title in the XML element describes in item with sub-data structure When minor structure title is identical, using the XML element as sub- root node, reads subordinate or be subordinated to each of sub- root node indirectly XML element, be subordinated to when subordinate or indirectly the XML element of sub- root node title described with subfield title in item it is identical and The type of the XML element and subfield describe the node type in item it is identical when, by the data of the XML element parsed The subfield is written in describe in item;
Judge whether the data of the XML element in the XML serialization message to be converted read out all have been written into phase The field description item or subfield answered describe item, if so, by after the data of write-in XML element the field description item or Subfield describes item and obtains the serialized data structure after data write-in, if it is not, field description is written in the XML element not being written Or subfield describe in item, the field description item or subfield describe the title of item and node type and described are not written The title of XML element is identical with type.
2. described according to the first structure of First ray message and described according to the method described in claim 1, wherein Corresponding relationship between one structure and the second structure of the second serialized message describes item formation sequence using the serializing of setting Changing data structure includes:
According to the first structure of First ray message and the first structure and the second structure of the second serialized message it Between corresponding relationship, using it is described serializing description item data structure the information in information and field description item in item is described By the correspondence setting in the serialized data structure of generation.
3. according to the method described in claim 2, wherein, the data structure using the serializing description item describes in item Information and field description item in information include: in the serialized data structure of generation by the correspondence setting
In data structure setting structure title and field description item in item described, the structure is entitled with first structure The title of root node in XML serialization message, includes data type, serial number, node type and title in the field description item, Serial number of the data in the PB serialized message with the second structure in field description item described in the serial number;
Structure title in item, the serial number in the field description item and title are described by the data structure by the correspondence Relationship is arranged in the serialized data structure of generation.
4. according to the method described in claim 2, wherein, the data structure, which describes sub-data structure is arranged in item, describes item, The sub-data structure describes to be provided with subfield in item and describes item, and the corresponding relationship includes being located at same data structure to describe Sub-data structure in describes the relationship of item Yu field description item;
The data structure using the serializing description item describes the information in information and field description item in item for institute State correspondence setting includes: in the serialized data structure of generation
Setting structure title in item, field description item and sub-data structure, which are described, in the data structure describes item, the structure The title of root node in the entitled XML serialization message with first structure, the sub-data structure describe to include sequence in item Number, minor structure title and subfield item is described, the field description item or the subfield describe to include data type, sequence in item Number, node type and title, field description item or subfield described in the serial number describe the data in item and have the second knot Serial number in the PB serialized message of structure;
Structure title in item is described by the data structure, the sub-data structure describes minor structure title in item, institute State field description item and the subfield describe serial number in item and title by the correspondence setting generation the sequence In columnization data structure.
5. described according to the correspondence recorded in the serialized data structure according to the method described in claim 1, wherein The serialized message that the data extracted are converted to the second format with the second structure includes: by relationship
According to the corresponding relationship recorded in the serialized data structure, the data type of data extracted is judged;
When the data extracted are the data of value type, following first methods is used to be handled: first will in a manner of variable The field description item or subfield describe the serial number of the data recorded in item and PB serialized message is written in data type In the corresponding data item of middle same sequence number, then the data of the value type are written in the data item;
When the data extracted are the data of character string type, following second methods is used to be handled: first in a manner of variable The serial number for the data that the field description item or subfield describe to record in item and data type write-in PB serializing are disappeared In breath in the corresponding data item of same sequence number, then data that the field description item or subfield are described to record in item String length is written in the data item, and then the data of the character string type are written in the data item;
When the data extracted are that sub-data structure describes item, first the sub-data structure is described in item in a manner of variable Serial number and structure type are written in PB serialized message in the corresponding data item of same sequence number, then the sub-data structure is described Data length is written in the data item in, then extracts the sub-data structure and describes the subfield of item and describes number in item According to, when the content extracted be value type data when, handled using the first method, when the content extracted is When the data of character string type, handled using the second method;
Judge whether the data extracted all have been written into PB serialized message in corresponding data item, if so, by write-in number Each data item after obtains the serialized message of the second format with the second structure, if it is not, according to the data not being written The data not being written are written in corresponding data item using the first method or second method for data type.
6. second format is XML format according to the method described in claim 4, wherein, first format is PB format When, it is described that the serialized message to be converted is parsed according to the serialized data structure, the data parsed are write Enter in the serialized data structure, the serialized data structure after obtaining data write-in includes:
The variate-value in the binary data stream of PB serialized message to be converted is read one by one;
The corresponding data type of the variate-value and serial number are obtained from the variate-value read;
When the variate-value read out is value type, is handled using following Third Way: continuing to read next variable Value, by serial number field description identical with the serial number of the variate-value in next variate-value write-in serialized data structure Item or subfield describe in item,
When the variate-value read out is character string type, is handled using following fourth way: continuing to read next change Magnitude obtains string length, then reads the byte of string length size again, obtains character string, and the character string is write Enter the field description item identical with the serial number of the character string of serial number in serialized data structure or subfield describes in item;
When the serial number of the variate-value read out is identical as the serial number that sub-data structure describes item, continue to read next variable Value, obtains data length, and the byte for then reading data length size again obtains bytecode set, and, read the byte Variate-value in code collection conjunction is handled using the Third Way when the variate-value read out is value type, works as reading When variate-value out is character string type, handled using the fourth way;
Judge whether all variate-values in PB serialized message to be converted all have been written into field description item or subfield Describe item in, if so, by after write-in variate-value the field description item or subfield describe item obtain data write-in after sequence Columnization data structure, if it is not, according to the data type for the variate-value not being written, using the Third Way or fourth way by institute It states the variate-value write-in field description item not being written or subfield describes in item.
7. described according to the correspondence recorded in the serialized data structure according to the method described in claim 6, wherein The serialized message that the data extracted are converted to the second format with the second structure includes: by relationship
According to the corresponding relationship recorded in the serialized data structure, judge whether the data extracted are structure title And judge the node type of the data extracted;
When the data extracted include that structure name claims, with the root in the data and structure title creation XML serialization message Node;
When the data extracted are node elements, following 5th modes are used to be handled: with described under the root node The field description item or subfield of node elements describe the creation XML node element of the title in item, and by field description item or son Data in field description item are written in the XML node element;
When the data extracted are nodal community, following 6th modes are used to be handled: with the section under present node The field description item or subfield of point attribute describe the creation XML node attribute of the title in item, and by field description item or sub- word Data in segment description item are written in the XML node attribute;
When the data extracted are that sub-data structure describes item, the title in item is described with the sub-data structure and creates sub- root Node extracts sub-data structure and describes the data in item, when the data extracted are node elements, uses under sub- root node 5th mode is handled, and when the data extracted are nodal community, is handled using the 6th mode;
Judge whether the data extracted all have been written into corresponding XML node element or XML node attribute, if so, by XML node element or XML node attribute after data write-in obtain the serialized message of the second format with the second structure, if It is no, according to the node type for the data not being written, the data not being written are write using above-mentioned 5th mode or the 6th mode Enter in corresponding XML node element or XML node attribute.
8. the conversion equipment between a kind of serialized message, comprising:
Data structure building unit, for the first structure and the first structure and the second sequence according to First ray message Corresponding relationship between second structure of columnization message describes item formation sequence data structure using the serializing of setting;Its In, First ray message has the first format, and the second serialized message has the second format, the first format, the second format point A kind of data format for serializing agreement is not corresponded to;The serializing description item includes that data structure describes item and is arranged in data Structure describes the field description item among item, and each data structure describes the structure of item and data structure describes each word among item The structure of segment description item is consistent with the first structure;
Writing unit is parsed, for the serialized message to be converted to the first format for meeting the first structure, according to described Serialized data structure parses the serialized message to be converted, and the serialized data is written in the data parsed Serialized data structure in structure, after obtaining data write-in;
Data extracting unit, for extracting the data in the serialized data structure after the data are written;
Converting unit, for according to the corresponding relationship recorded in the serialized data structure, the data extracted to be turned It is changed to the serialized message of the second format with the second structure;
First format is XML format, when second format is PB format,
The parsing writing unit, for according to the serialized data structure to the XML in XML serialization message to be converted Element is read out, when title and the data structure in the XML element read out describe the structure title in item it is identical when, determine The corresponding XML node of the XML element is root node;It reads subordinate or is subordinated to each XML element of root node indirectly, when described The type of the title XML element identical and described with the title in field description item in XML element and the section in field description item When vertex type is identical, the data of the XML element parsed are written in the field description item;When the XML element In title and sub-data structure describe the minor structure title in item it is identical when, using the XML element as sub- root node, read Subordinate or each XML element for being subordinated to sub- root node indirectly are subordinated to the title of the XML element of sub- root node when subordinate or indirectly And it is identical that subfield describes the node type that the title in item is identical and the type of the XML element is described with subfield in item When, the data of the XML element parsed are written in the subfield and are described in item;Judgement is read out described to be converted XML serialization message in the data of XML element whether all have been written into the corresponding field description item or subfield Describe item, if so, by after the data of write-in XML element the field description item or subfield describe item obtain data write-in after Serialized data structure, described in item if it is not, field description item or subfield is written in the XML element not being written, the word Segment description item or subfield describe item title and node type it is identical as the title of the XML element not being written and type.
9. device according to claim 8, wherein the data structure building unit includes correspondence setting unit, For first structure and the first structure and the second serialized message according to First ray message the second structure it Between corresponding relationship, using it is described serializing description item data structure the information in information and field description item in item is described By the correspondence setting in the serialized data structure of generation.
10. device according to claim 9, wherein the correspondence setting unit, for being retouched in the data structure State setting structure title and field description item in item, root in the entitled XML serialization message with first structure of the structure The title of node includes data type, serial number, node type and title, word described in the serial number in the field description item Serial number of the data in the PB serialized message with the second structure in segment description item;It is described in item by the data structure Structure title, the serial number in the field description item and title by the correspondence setting generation the serializing number According in structure.
11. device according to claim 9, wherein the data structure building unit includes minor structure setting unit, is used Item is described in describing setting sub-data structure in item in the data structure, wherein the sub-data structure describes to be arranged in item There is subfield to describe item, the corresponding relationship includes that the sub-data structure described in item positioned at same data structure describes item and word The relationship of segment description item;
The correspondence setting unit, for the data structure describe setting structure title in item, field description item and Sub-data structure describes item, and the title of root node, described in the entitled XML serialization message with first structure of the structure Sub-data structure describes to include that serial number, minor structure title and subfield describe item, the field description item or the sub- word in item It include data type, serial number, node type and title in segment description item, field description item described in the serial number or subfield are retouched State serial number of the data in the PB serialized message with the second structure in item;Knot in item is described by the data structure Structure title, the sub-data structure describe minor structure title, the field description item and the subfield in item and describe in item Serial number and title by the correspondence setting in the serialized data structure of generation.
12. device according to claim 8, wherein the converting unit, for according in the serialized data structure The corresponding relationship of record, judges the data type of data extracted;When the data that the data extracted are value type When, it uses following first methods to be handled: first describing to record in item by the field description item or subfield in a manner of variable The data serial number and data type write-in PB serialized message in the corresponding data item of same sequence number, then by the number The data of Value Types are written in the data item;
When the data extracted are the data of character string type, following second methods is used to be handled: first in a manner of variable The serial number for the data that the field description item or subfield describe to record in item and data type write-in PB serializing are disappeared In breath in the corresponding data item of same sequence number, then data that the field description item or subfield are described to record in item String length is written in the data item, and then the data of the character string type are written in the data item;
When the data extracted are that sub-data structure describes item, first the sub-data structure is described in item in a manner of variable Serial number and structure type are written in PB serialized message in the corresponding data item of same sequence number, then the sub-data structure is described Data length is written in the data item in, then extracts the sub-data structure and describes the subfield of item and describes number in item According to, when the data extracted be value type data when, handled using the first method, when the data extracted are When the data of character string type, handled using the second method;Judge whether the data extracted all have been written into PB In serialized message in corresponding data item, if so, obtaining second with the second structure by each data item after write-in data The serialized message of format, if it is not, according to the data type for the data not being written, using the first method or second method, The data not being written are written in corresponding data item.
13. device according to claim 11, wherein first format is PB format, and second format is XML lattice When formula, the parsing writing unit, the variate-value in binary data stream for reading PB serialized message to be converted one by one;
The corresponding data type of the variate-value and serial number are obtained from the variate-value read;
When the variate-value read out is value type, is handled using following Third Way: continuing to read next variable Value, by serial number field description identical with the serial number of the variate-value in next variate-value write-in serialized data structure Item or subfield describe in item,
When the variate-value read out is character string type, is handled using following fourth way: continuing to read next change Magnitude obtains string length, then reads the byte of string length size again, obtains character string, and the character string is write Enter the field description item identical with the serial number of the character string of serial number in serialized data structure or subfield describes in item;
When the serial number of the variate-value read out is identical as the serial number that sub-data structure describes item, continue to read next variable Value, obtains data length, and the byte for then reading data length size again obtains bytecode set, and, read the byte Variate-value in code collection conjunction is handled using the Third Way when the variate-value read out is value type, works as reading When variate-value out is character string type, handled using the fourth way;
Judge whether all variate-values in PB serialized message to be converted all have been written into field description item or subfield Describe item in, if so, by after write-in variate-value the field description item or subfield describe item obtain data write-in after sequence Columnization data structure, if it is not, according to the data type for the variate-value not being written, using the Third Way or fourth way by institute It states the variate-value write-in field description item not being written or subfield describes in item.
14. device according to claim 13, wherein the converting unit, for according to the serialized data structure The corresponding relationship of middle record judges whether the data extracted are structure title and the node for judging the data extracted Type;When the data extracted include that structure name claims, with the root in the data and structure title creation XML serialization message Node;
When the data extracted are node elements, following 5th modes are used to be handled: with described under the root node The field description item or subfield of node elements describe the creation XML node element of the title in item, and by field description item or son Data in field description item are written in the XML node element;
When the data extracted are nodal community, following 6th modes are used to be handled: with the section under present node The field description item or subfield of point attribute describe the creation XML node attribute of the title in item, and by field description item or sub- word Data in segment description item are written in the XML node attribute;
When the data extracted are that sub-data structure describes item, the title in item is described with the sub-data structure and creates sub- root Node extracts sub-data structure and describes the data in item, when the data extracted are node elements, uses under sub- root node 5th mode is handled, and when the data extracted are nodal community, is handled using the 6th mode;
Judge whether the data extracted all have been written into corresponding XML node element or XML node attribute, if so, by XML node element or XML node attribute after data write-in obtain the serialized message of the second format with the second structure, if It is no, according to the node type for the data not being written, the data not being written are write using above-mentioned 5th mode or the 6th mode Enter in corresponding XML node element or XML node attribute.
CN201380081227.7A 2013-12-31 2013-12-31 Conversion method and device between serialized message Active CN105793842B (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2013/091193 WO2015100652A1 (en) 2013-12-31 2013-12-31 Method and apparatus for performing conversion among serialized messages

Publications (2)

Publication Number Publication Date
CN105793842A CN105793842A (en) 2016-07-20
CN105793842B true CN105793842B (en) 2019-10-18

Family

ID=53492994

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201380081227.7A Active CN105793842B (en) 2013-12-31 2013-12-31 Conversion method and device between serialized message

Country Status (2)

Country Link
CN (1) CN105793842B (en)
WO (1) WO2015100652A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108628885B (en) * 2017-03-20 2023-04-18 腾讯科技(深圳)有限公司 Data synchronization method and device and storage equipment
CN111931200B (en) * 2020-07-13 2024-02-23 车智互联(北京)科技有限公司 Data serialization method, mobile terminal and readable storage medium
CN115623087B (en) * 2022-11-21 2023-02-28 飞天诚信科技股份有限公司 Method and system for analyzing PB format circulation data

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2432930A (en) * 2005-12-01 2007-06-06 Honeywell Int Inc Translating format of configuration data when updating software
CN101931548A (en) * 2009-06-24 2010-12-29 华为技术有限公司 Method, apparatus and system for label management of access network
CN102420862A (en) * 2011-11-29 2012-04-18 上海计算机软件技术开发中心 Internet of things middleware message description structure and form conversion method thereof
CN102810069A (en) * 2012-07-16 2012-12-05 深圳市融创天下科技股份有限公司 JAVA object requesting and responding methods, devices and systems and terminal

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102185901B (en) * 2011-04-19 2013-06-26 北京思特奇信息技术股份有限公司 Client message conversion method
US20130304510A1 (en) * 2012-05-08 2013-11-14 Drfirst.Com, Inc. Health information exchange system and method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB2432930A (en) * 2005-12-01 2007-06-06 Honeywell Int Inc Translating format of configuration data when updating software
CN101931548A (en) * 2009-06-24 2010-12-29 华为技术有限公司 Method, apparatus and system for label management of access network
CN102420862A (en) * 2011-11-29 2012-04-18 上海计算机软件技术开发中心 Internet of things middleware message description structure and form conversion method thereof
CN102810069A (en) * 2012-07-16 2012-12-05 深圳市融创天下科技股份有限公司 JAVA object requesting and responding methods, devices and systems and terminal

Also Published As

Publication number Publication date
WO2015100652A1 (en) 2015-07-09
CN105793842A (en) 2016-07-20

Similar Documents

Publication Publication Date Title
TWI334551B (en) Method and computer-readable medium for improting and exporting hierarchically structured data
CN103294652B (en) A kind of data transfer device and system
CN106970820A (en) Code storage method and code storage
CN102185901A (en) Client message conversion method
CN102023856A (en) Method for outputting and operating data at server in formatting way according to demands of user
CN102566984B (en) Method and device for configuring parameters
US20090083315A1 (en) Information processing apparatus and encoding method
CN101526963A (en) Method for identifying web page coding, device and terminal equipment
CN111131403A (en) Message coding and decoding method and device for Internet of things equipment
CN105793842B (en) Conversion method and device between serialized message
US20080313291A1 (en) Method and apparatus for encoding data
JP2006216027A (en) Mechanism for transferring raw data from one data structure to another representing the same item
US7565339B2 (en) Knowledge based encoding of data
CN110020412B (en) Method and device for generating IMIX standard message and electronic equipment
JP2008134906A (en) Business process definition generation method, device and program
CN101944133A (en) XML metadata objectification analytic method and system
CN105786529B (en) One type Managed Code calls the Parameters design of the labyrinth of C/C++ style function
CN103646015B (en) Transmission, the method and system for receiving and transmitting XML message
CN105005496B (en) A kind of processing system and method for across language conversion network data package definition file
CN106776285A (en) Webpage front-end adjustment method and device
CN107832046A (en) Data creation method and device
CN111782882A (en) TCP message conversion method, device, system and computer storage medium
CN102314406A (en) The method and system that is used for the lazy data sequenceization of compunication
JP2013218627A (en) Method and device for extracting information from structured document and program
US20050091405A1 (en) Method and system for using multiple data type representations to deliver data objects to components in a distributed system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP02 Change in the address of a patent holder

Address after: Room 810, 8 / F, 34 Haidian Street, Haidian District, Beijing 100080

Patentee after: BEIJING D-MEDIA COMMUNICATION TECHNOLOGY Co.,Ltd.

Address before: 100089 Beijing city Haidian District wanquanzhuang Road No. 28 Wanliu new building 6 storey block A room 602

Patentee before: BEIJING D-MEDIA COMMUNICATION TECHNOLOGY Co.,Ltd.

CP02 Change in the address of a patent holder