CN111294320B - Data conversion method and device - Google Patents
Data conversion method and device Download PDFInfo
- Publication number
- CN111294320B CN111294320B CN201811498079.XA CN201811498079A CN111294320B CN 111294320 B CN111294320 B CN 111294320B CN 201811498079 A CN201811498079 A CN 201811498079A CN 111294320 B CN111294320 B CN 111294320B
- Authority
- CN
- China
- Prior art keywords
- protocol
- target input
- data
- target
- target output
- 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
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/08—Protocols for interworking; Protocol conversion
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Communication Control (AREA)
- Computer And Data Communications (AREA)
Abstract
The disclosure relates to a data conversion method and device, and belongs to the technical field of software. The method comprises the following steps: acquiring first data based on a target input protocol; acquiring a mapping relation template according to a target input protocol, wherein the mapping relation template comprises a first mapping relation between the structural elements of the target input protocol and the structural elements of the target output protocol, and a second mapping relation between the association relation between the structural elements of the target input protocol and the association relation between the structural elements of the target output protocol; and generating second data based on the target output protocol according to the first data, the first mapping relation and the second mapping relation. Compared with a mode of manually converting data, the method provided by the embodiment of the disclosure can automatically convert the content and the structure of the first data based on the target input protocol, thereby saving a large amount of manpower and greatly improving the conversion efficiency.
Description
Technical Field
The present disclosure relates to the field of software technologies, and in particular, to a method and an apparatus for data conversion.
Background
In the prior art, each equipment company develops its own equipment autonomously. These devices have different functions and different systems mounted on the devices. When an integration project is made, the devices can be integrated together for use. At this time, communication between the devices is inevitably required.
However, since there is no standard protocol, if data transmitted from a transmitting end is received by a receiving end using a different protocol, the receiving end cannot correctly parse the data.
In carrying out the present disclosure, the inventors found that at least the following problems exist:
the received data needs to be converted manually by a programmer, so that the receiving end can correctly analyze the converted data. But this results in a lot of manpower and less efficient conversion.
Disclosure of Invention
In order to overcome the problems in the related art, the present disclosure provides the following technical solutions:
according to a first aspect of embodiments of the present disclosure, there is provided a method of data conversion, the method including:
acquiring first data based on a target input protocol;
acquiring a mapping relation template according to the target input protocol, wherein the mapping relation template comprises a first mapping relation between the structural elements of the target input protocol and the structural elements of the target output protocol, and a second mapping relation between the association relation between the structural elements of the target input protocol and the association relation between the structural elements of the target output protocol;
and generating second data based on the target output protocol according to the first data, the first mapping relation and the second mapping relation.
Optionally, the generating second data based on a target output protocol according to the first data, the first mapping relationship, and the second mapping relationship includes:
determining the constituent elements contained in the target output protocol according to the constituent elements contained in the target input protocol and the first mapping relation;
constructing an incidence relation among the components of the target output protocol according to the second mapping relation and the incidence relation among the components of the target input protocol;
generating data included in each component of the target output protocol according to the data included in each component of the target input protocol;
outputting the second data based on the target output protocol.
Optionally, the method further comprises: acquiring a node tree corresponding to the target input protocol, wherein each component of the target input protocol corresponds to a node in the node tree, and the association relationship among the components of the target input protocol is specifically the association relationship among the nodes in the node tree;
and constructing a node tree corresponding to the target output protocol according to the node tree corresponding to the target input protocol.
Optionally, the type of the target input protocol includes one or more, the type of the target output protocol includes one or more, and when the type of the target input protocol and/or the type of the target output protocol are multiple, before the method, the method further includes:
generating a unique protocol identifier according to a predetermined rule according to the constituent elements contained in each type of target input protocol and/or the constituent elements contained in the corresponding type of target output protocol;
the protocol identification and a corresponding mapping relation template between the corresponding target input protocol and the corresponding target output protocol are subjected to associated storage;
generating a protocol identifier in real time according to the type of the target input protocol of the acquired first data and/or the determined type of the target output protocol;
the obtaining a mapping relation template according to the target input protocol includes: and acquiring a corresponding mapping relation template according to the protocol identifier generated in real time.
Optionally, after the obtaining the first data based on the target input protocol, the method further includes:
determining the format of the first data, and converting the format of the first data into a preset format if the format of the first data is not the preset format.
According to a second aspect of the embodiments of the present disclosure, there is provided an apparatus for data conversion, the apparatus comprising:
the acquisition module is used for acquiring first data based on a target input protocol; acquiring a mapping relation template according to the target input protocol, wherein the mapping relation template comprises a first mapping relation between the structural elements of the target input protocol and the structural elements of the target output protocol, and a second mapping relation between the association relation between the structural elements of the target input protocol and the association relation between the structural elements of the target output protocol;
and the generating module is used for generating second data based on the target output protocol according to the first data, the first mapping relation and the second mapping relation.
Optionally, the generating module is configured to:
determining the constituent elements contained in the target output protocol according to the constituent elements contained in the target input protocol and the first mapping relation;
constructing an incidence relation among the components of the target output protocol according to the second mapping relation and the incidence relation among the components of the target input protocol;
generating data included in each component of the target output protocol according to the data included in each component of the target input protocol;
outputting the second data based on the target output protocol.
Optionally, the obtaining module is further configured to obtain a node tree corresponding to the target input protocol, where each component of the target input protocol corresponds to a node in the node tree, and an association relationship between the components of the target input protocol is specifically an association relationship between nodes in the node tree;
the device further comprises:
and the establishing module is used for establishing the node tree corresponding to the target output protocol according to the node tree corresponding to the target input protocol.
Optionally, the types of the target input protocols include one or more, the types of the target output protocols include one or more, and the generating module is further configured to generate a unique protocol identifier according to a predetermined rule according to a constituent element included in each type of target input protocol and/or a constituent element included in a corresponding type of target output protocol;
the device further comprises:
the storage module is used for performing associated storage on the protocol identification and a corresponding mapping relation template between the corresponding target input protocol and the corresponding target output protocol;
the generating module is further configured to generate a protocol identifier in real time according to the type of the target input protocol of the acquired first data and/or the determined type of the target output protocol;
and the acquisition module is used for acquiring the corresponding mapping relation template according to the protocol identifier generated in real time.
Optionally, the apparatus further comprises:
and the conversion module is used for determining the format of the first data, and converting the format of the first data into the preset format if the format of the first data is not the preset format.
According to a third aspect of the embodiments of the present disclosure, there is provided a terminal, which includes a processor and a memory, where at least one instruction, at least one program, a code set, or a set of instructions is stored in the memory, and the at least one instruction, the at least one program, the code set, or the set of instructions is loaded and executed by the processor to implement the above-mentioned data conversion method.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium having at least one instruction, at least one program, a set of codes, or a set of instructions stored therein, which is loaded and executed by a processor to implement the above-mentioned data conversion method.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
according to the method provided by the embodiment of the disclosure, the first data based on the target input protocol can be converted based on the content recorded in the mapping relation template, and the second data based on the target output protocol is obtained. In the conversion process, not only the components of the target input protocol may be converted into the components of the target output protocol, but also the relationship between the components of the target input protocol may be converted into the relationship between the components of the target output protocol, and finally, the first data based on the target input protocol may be converted into the second data based on the target output protocol. Compared with a mode of manually converting data, the method provided by the embodiment of the disclosure can automatically convert the content and the structure of the first data based on the target input protocol, thereby saving a large amount of manpower and greatly improving the conversion efficiency.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. In the drawings:
FIG. 1 is a flow diagram illustrating a method of data conversion in accordance with an exemplary embodiment;
FIG. 2 is a diagram illustrating a mapping relationship in accordance with an exemplary embodiment;
FIG. 3 is a diagram illustrating a mapping relationship in accordance with an exemplary embodiment;
FIG. 4 is a diagram illustrating a mapping relationship in accordance with an exemplary embodiment;
FIG. 5 is a diagram illustrating a mapping relationship in accordance with an exemplary embodiment;
FIG. 6 is a block diagram illustrating an apparatus for data conversion in accordance with an exemplary embodiment;
fig. 7 is a schematic diagram illustrating a structure of a terminal according to an exemplary embodiment.
With the foregoing drawings in mind, certain embodiments of the disclosure have been shown and described in more detail below. These drawings and written description are not intended to limit the scope of the disclosed concepts in any way, but rather to illustrate the concepts of the disclosure to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
The embodiment of the disclosure provides a data conversion method, which can be implemented by a terminal. The terminal can be a mobile phone, a tablet computer, a desktop computer, a notebook computer and the like.
An exemplary embodiment of the present disclosure provides a method for data conversion, and as shown in fig. 1, a processing flow of the method may include the following steps:
in step S110, first data based on the target input protocol is acquired.
In implementation, the method provided by the embodiment of the present disclosure may be executed in a terminal, where the terminal may serve as a receiving end for receiving first data, the sending end may send the first data based on the target input protocol to the receiving end, and the receiving end may receive the first data based on the target input protocol. The first data based on the target input protocol is generated in a transmitting end, and the transmitting end adopts the target input protocol to generate the first data based on the target input protocol. If the target input protocol is not used in the receiving end, the protocol used by the transmitting end is inconsistent with the protocol used by the receiving end, and the receiving end may not be able to correctly analyze the first data based on the target input protocol. Therefore, the method provided by the embodiment of the present disclosure may be used to convert the first data based on the target input protocol into the second data based on the target output protocol, which may be correctly analyzed by the receiving end locally or by another terminal connected to the receiving end. The target input protocol can be an alarm protocol, a picture protocol, a people flow protocol, a stock data protocol and the like. The first data may be data in the form of a message.
And step S120, acquiring a mapping relation template according to the target input protocol.
The mapping relation template comprises a first mapping relation between the structural elements of the target input protocol and the structural elements of the target output protocol, and a second mapping relation between the association relation between the structural elements of the target input protocol and the association relation between the structural elements of the target output protocol.
In implementation, since the receiving end receives data based on different input protocols sent by different sending ends, the mapping relation templates used in the conversion process are different for the data based on different input protocols. In order to convert the first data based on the target input protocol through the mapping relation template corresponding to the target input protocol, before data conversion is performed, the protocol identifier of the target input protocol may be determined first, and the mapping relation template may be obtained based on the protocol identifier of the target input protocol.
Optionally, the type of the target input protocol includes one or more, the type of the target output protocol includes one or more, and when the type of the target input protocol and/or the type of the target output protocol are multiple, the method further includes, before the step: generating a unique protocol identifier according to a predetermined rule according to the constituent elements contained in each type of target input protocol and/or the constituent elements contained in the corresponding type of target output protocol; carrying out associated storage on the protocol identification and a corresponding mapping relation template between a corresponding target input protocol and a corresponding target output protocol; generating a protocol identifier in real time according to the type of a target input protocol of the acquired first data and/or the determined type of a target output protocol; according to the target input protocol, the step of obtaining the mapping relation template may include: and acquiring a corresponding mapping relation template according to the protocol identifier generated in real time.
In an implementation, the type of the target input protocol may not be only one, the type of the target output protocol may not be only one, the type of the target input protocol may include one or more, and the type of the target output protocol may include one or more. When the type of the target input protocol or the type of the target output protocol is multiple, and the type of the target input protocol and the type of the target output protocol are multiple at the same time, in order to distinguish the target input protocols from the target output protocols, a unique protocol identifier can be generated according to a predetermined rule according to a component element included in each type of target input protocol or a component element included in the corresponding type of target output protocol; and generating a unique protocol identifier according to the components contained in each type of target input protocol and the components contained in the corresponding type of target output protocol and a preset rule.
A unique protocol identification may be generated by a recursive algorithm from the components comprised by each type of target input protocol and/or the components comprised by the corresponding type of target output protocol. Or the components contained in each type of target input protocol and/or the components contained in the corresponding type of target output protocol may be recursively ordered to obtain a unique protocol identifier.
A method for generating a unique protocol identifier based on a recursive algorithm from the components included in each type of target input protocol and/or the components included in the corresponding type of target output protocol will be described in detail below.
In the first data based on the same input protocol, the component does not change, and the data included in the component changes. Therefore, recursive ordering can be performed for invariant constituent elements based on a recursive algorithm to obtain a long string, and then the long string can be used as a protocol identifier. For example, the content of the first data alarmMess is as follows:
the first data alarmMess is data in JSON (JavaScript Object Notation) format, and data is structured by colon, double quotation marks, and braces in the JSON-format data, and as "MesgType" in the first data alarmMess, "PUBLISH" is content in the double quotation marks that is data included in the constituent elements and the constituent elements, MesgType is a constituent element, colon is an assignment value, PUBLISH is data included in the constituent elements, that is, data included in the constituent element MesgType is PUBLISH. By analogy, all the components in the first data alarmMess are recursively ordered to form a long string: the protocol identifier is alarmMessMesgTypeAlamTypeAlarmsTtypeEventialAlmTimester 2str1 AlarmstpicFile.
Alternatively, if the data type of the component in the first data is an array type, the component of the array type includes a plurality of sub-components, the identification of each sub-component is similar and the number of sub-components is large, and therefore, when the component of the array type is encountered, the components of the array type may not be recursively ordered.
After the protocol identifier is determined, the protocol identifier and a mapping relation template corresponding to the target input protocol and the target output protocol can be stored in an associated manner, so that each mapping relation template corresponds to a unique protocol identifier, and then the corresponding mapping relation template can be searched through the protocol identifier.
After the receiving end receives the first data based on the target input protocol, in order to determine the mapping relationship template to be used, the protocol identifier may be generated in real time, so that the corresponding mapping relationship template may be obtained according to the protocol identifier generated in real time. In the process of generating the protocol identifier in real time, the protocol identifier may be generated in real time according to the type of the target input protocol of the acquired first data or the determined type of the target output protocol; the protocol identifier can also be generated in real time according to the type of the target input protocol of the acquired first data and the determined type of the target output protocol. Finally, the corresponding mapping relation template can be obtained according to the protocol identifier generated in real time.
The mapping relation template comprises a first mapping relation between the components of the target input protocol and the components of the target output protocol, and a second mapping relation between the association relation between the components of the target input protocol and the association relation between the components of the target output protocol.
The first mapping relationship may be a correspondence relationship between each component of the target input protocol and each component of the target output protocol, and data included in any one of the components of the target output protocol may be recorded from which component of the target input protocol is acquired. The second mapping relationship may be a relationship between components of the target input protocol and a relationship between components of the target output protocol, and how the structure between the components of the target output protocol is converted by the structure between the components of the target input protocol may be recorded.
As shown in fig. 2, the target input protocol may be mapped to the target output protocol by a mapping relation template, and specifically, first data based on the target input protocol may be converted into second data based on the target output protocol by the mapping relation template.
As shown in FIG. 3, the input protocol is on the left side of the diagram, and the mapping relation template and the output protocol are on the right side of the diagram. The mapping relationship template may be obtained according to the target input protocol based on the relationship diagram shown in fig. 3.
The relationship between the input protocol and the mapping relationship template and the output protocol shown in fig. 3 may be manually configured as the content of the configuration file, and after the configuration is completed, the configuration file may be stored in the memory. The configuration file can be added, deleted and modified to modify the mapping relation template, so that the modified mapping relation template meets the actual use requirement.
If a software program is used for performing the protocol conversion operation in the device for performing the protocol conversion, the software program needs to be started first when the protocol conversion operation is required. When the software program is started, the configuration file is automatically loaded, and the content in the configuration file is read. The software program can be a stand-alone software program, can depend on other software programs in a plug-in mode, or can exist in a library file mode. Still alternatively, it may exist in the form of providing a data conversion service in the server.
How the components of the target input protocol are mapped to the components of the target output protocol is recorded in the mapping relation template. For example, the constituent element of the target input protocol is MesgType. The constituent element of the target output protocol is MessageType. If there is a correspondence between the MesgType of the target input protocol and the MessageType of the target output protocol, and the MesgType belongs to the alarmMess, and the MessageType belongs to the AlarmMessage, the mapping relationship template may record: "/almMess/MesgType/"/AlarmMessage/MessageType/". It can also be considered as a path mapping relationship that the data item alarmMess is found first, and the data item MesgType is found below the data item alarmMess. Similarly, the data item AlarmMessage is found first, and then the data item MessageType is found below the data item AlarmMessage. That is, the mapping relation template records what path is used to find a pair of corresponding components.
Alternatively, before performing step S110, the format of the first data may be determined, and if the format of the first data is not the preset format, the format of the first data is converted into the preset format.
In an implementation, the format of the first data may include a JSON format, an XML (Extensible markup Language) format, an MML (Man-Machine Language) format, and the like, and the preset format may be the JSON format. The data in the JSON format is the data stored in the form of attribute key value pairs, and the storage mode determines that the storage space occupied by the data in the JSON format is small, so that the first data in the non-JSON format, such as the first data in the XML format and the first data in the MML format, can be converted into the first data in the JSON format through a protocol format conversion algorithm.
Step S130, generating second data based on the target output protocol according to the first data, the first mapping relation and the second mapping relation.
In an implementation, the data included in each component in the target input protocol may be used as a data source for each component in the target output protocol. The constituent elements of the target output protocol AlarmMessage can be seen in the following example:
{
"AlarmMessage":{
"MessageType":"ceshi",
"AlarmMainType":"ceshi",
"AlarmSubType":"ceshi",
"Params":
{
"EventGUID":"ceshi",
"AlarmStatus":"ceshi",
"AlarmTime":"ceshi",
"StrRev1":"ceshi",
"StrRev2":"ceshi",
"PicFile":[{
"PicUrl":"ceshi",
"FileName":"ceshi"}]
}
}
}
in the target AlarmMessage, "ceshi" is the location to wait for data to be filled, and the data source for the filled data may be the first data based on the target input protocol. The mapping relationship template may be:
{
"/alarmMess/MesgType/":"/AlarmMessage/MessageType/",
"/alarmMess/AlamMtype/":"/AlarmMessage/AlarmMainType/",
"/alarmMess/AlarmStype/":"/AlarmMessage/AlarmSubType/",
"/alarmMess/Eventid/":"/AlarmMessage/Params/EventGUID/",
"/alarmMess/Alarmst/":"/AlarmMessage/Params/AlarmStatus/",
"/alarmMess/alarmTime/":"/AlarmMessage/Params/AlarmTime/",
"/alarmMess/str1/":"/AlarmMessage/Params/StrRev1/",
"/alarmMess/str2/":"/AlarmMessage/Params/StrRev2/",
"/alarmMess/picFile/":"/AlarmMessage/Params/PicFile/",
"/alarmMess/picFile//filename/":"/AlarmMessage/Params/PicFile//FileName/",
"/alarmMess/picFile//url/":"/AlarmMessage/Params/PicFile//PicUrl/"
}
alternatively, step S130 may include: determining the constituent elements contained in the target output protocol according to the constituent elements contained in the target input protocol and the first mapping relation; constructing an incidence relation among the components of the target output protocol according to the second mapping relation and the incidence relation among the components of the target input protocol; generating data included in each component of the target output protocol according to the data included in each component of the target input protocol; outputting the second data based on the target output protocol.
In implementation, as shown in fig. 4, first, the components included in the target output protocol may be determined according to the components included in the target input protocol and the first mapping relationship. And then, constructing the association relationship among the components of the target output protocol according to the second mapping relationship and the association relationship among the components of the target input protocol. Fig. 4 shows an example of the first mapping relationship and the second mapping relationship. Finally, generating data contained in each component of the target output protocol according to the data contained in each component of the target input protocol; outputting the second data based on the target output protocol.
Optionally, the method provided by the embodiment of the present disclosure may further include: acquiring a node tree corresponding to a target input protocol, wherein each constituent element of the target input protocol corresponds to one node in the node tree, and the association relationship among the constituent elements of the target input protocol is specifically the association relationship among the nodes in the node tree; and constructing a node tree corresponding to the target output protocol according to the node tree corresponding to the target input protocol.
In implementation, as shown in fig. 5, a node tree corresponding to a target input protocol may be obtained, where each component of the target input protocol corresponds to one node in the node tree, and an association relationship between components of the target input protocol is specifically an association relationship between nodes in the node tree. Then, a node tree corresponding to the target output protocol can be constructed according to the node tree corresponding to the target input protocol. Fig. 5 shows an example of a node tree corresponding to a target input protocol and a node tree corresponding to a target output protocol. Each node in the node tree corresponding to the target input protocol can be traversed, and the node tree corresponding to the target output protocol is constructed according to the node tree corresponding to the target input protocol.
Alternatively, the component may be an array type component, and the array type component may include a plurality of sub-components. The mapping relationship between the constituent elements of the array type of the target input protocol and the constituent elements of the array type of the target output protocol may be recorded in the mapping relationship template. The mapping relation between a plurality of sub-components included in the component of the array type of the target input protocol and a plurality of sub-components included in the component of the array type of the target output protocol is determined based on the mapping relation between the component of the array type of the target input protocol and the component of the array type of the target output protocol. The data of the array type based on the target output protocol is generated based on a mapping relationship among the data of the array type in the first data, the plurality of sub-constituent elements included in the constituent element of the array type of the target input protocol, and the plurality of sub-constituent elements included in the constituent element of the array type of the target output protocol.
Alternatively, a first component of the array type may be specified among the components of the target input protocol in the first mapping relationship, and a second component of the target output protocol corresponding to the first component may be specified in the first mapping relationship. The other components belonging to the same array corresponding to the first component are identified, and the other components belonging to the same array corresponding to the second component are identified. And determining a third mapping relation between the other components belonging to the same array and corresponding to the first component and the other components belonging to the same array and corresponding to the second component based on the sequence of the other components belonging to the same array and corresponding to the first component and the sequence of the other components belonging to the same array and corresponding to the second component. Adding the third mapping relationship to the first mapping relationship. And generating second data based on the target output protocol based on the first data, the first mapping relation and the second mapping relation.
For example, the array picFile [2] [ { "filename": 2017-10-3110: 09 Hangzhou 1"," filesize ": 10234", "url": https:// 10.67.188.1/vms/index! 1"}, {" filename ": 2017-10-3110: 15 Hangzhou 2]," filesize ":10234," url ": https:// 10.67.188.1/vms/index! 2"} ], there are two sub-components in the array picFile, each sub-component including filename, filesize and url. When the first mapping relationship is configured, it is only necessary to configure the first sub-component in the array, and the first mapping relationships of other sub-components can be determined based on the first mapping relationship of the first sub-component.
According to the method provided by the embodiment of the disclosure, the first data based on the target input protocol can be converted based on the content recorded in the mapping relation template, and the second data based on the target output protocol is obtained. In the conversion process, not only the components of the target input protocol may be converted into the components of the target output protocol, but also the relationship between the components of the target input protocol may be converted into the relationship between the components of the target output protocol, and finally, the first data based on the target input protocol may be converted into the second data based on the target output protocol. Compared with a mode of manually converting data, the method provided by the embodiment of the disclosure can automatically convert the content and the structure of the first data based on the target input protocol, so that a great deal of manpower can be saved, and the conversion efficiency is greatly improved.
Yet another exemplary embodiment of the present disclosure provides an apparatus for data conversion, as shown in fig. 6, the apparatus including:
an obtaining module 610, configured to obtain first data based on a target input protocol; acquiring a mapping relation template according to the target input protocol, wherein the mapping relation template comprises a first mapping relation between the structural elements of the target input protocol and the structural elements of the target output protocol, and a second mapping relation between the association relation between the structural elements of the target input protocol and the association relation between the structural elements of the target output protocol;
a generating module 620, configured to generate second data based on the target output protocol according to the first data, the first mapping relationship, and the second mapping relationship.
Optionally, the generating module 620 is configured to:
determining the constituent elements contained in the target output protocol according to the constituent elements contained in the target input protocol and the first mapping relation;
constructing an incidence relation among the components of the target output protocol according to the second mapping relation and the incidence relation among the components of the target input protocol;
generating data included in each component of the target output protocol according to the data included in each component of the target input protocol;
outputting the second data based on the target output protocol.
Optionally, the obtaining module 610 is further configured to obtain a node tree corresponding to the target input protocol, where each component of the target input protocol corresponds to a node in the node tree, and an association relationship between the components of the target input protocol is specifically an association relationship between nodes in the node tree;
the device further comprises:
and the establishing module is used for establishing the node tree corresponding to the target output protocol according to the node tree corresponding to the target input protocol.
Optionally, the types of the target input protocols include one or more types, the types of the target output protocols include one or more types, and the generating module 620 is further configured to generate a unique protocol identifier according to a predetermined rule according to a component included in each type of target input protocol and/or a component included in a corresponding type of target output protocol;
the device further comprises:
the storage module is used for performing associated storage on the protocol identification and a corresponding mapping relation template between the corresponding target input protocol and the corresponding target output protocol;
the generating module 620 is further configured to generate a protocol identifier in real time according to the type of the target input protocol of the acquired first data and/or the determined type of the target output protocol;
the obtaining module 610 is configured to obtain a corresponding mapping relation template according to the protocol identifier generated in real time.
Optionally, the apparatus further comprises:
and the conversion module is used for determining the format of the first data, and converting the format of the first data into the preset format if the format of the first data is not the preset format.
With regard to the apparatus in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be described in detail here.
The device provided by the embodiment of the disclosure can convert first data based on a target input protocol based on the content recorded in the mapping relation template to obtain second data based on a target output protocol. In the conversion process, not only the components of the target input protocol may be converted into the components of the target output protocol, but also the relationship between the components of the target input protocol may be converted into the relationship between the components of the target output protocol, and finally, the first data based on the target input protocol may be converted into the second data based on the target output protocol. Compared with a mode of manually converting data, the method provided by the embodiment of the disclosure can automatically convert the content and the structure of the first data based on the target input protocol, thereby saving a large amount of manpower and greatly improving the conversion efficiency.
It should be noted that: in the data conversion apparatus provided in the foregoing embodiment, only the division of the functional modules is illustrated when performing data conversion, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the terminal is divided into different functional modules to complete all or part of the functions described above. In addition, the data conversion apparatus and the data conversion method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.
Fig. 7 is a schematic diagram illustrating a structure of a terminal 1800 according to an exemplary embodiment of the present invention. The terminal 1800 may be: a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III, motion video Experts compression standard Audio Layer 3), an MP4 player (Moving Picture Experts Group Audio Layer IV, motion video Experts compression standard Audio Layer 4), a notebook computer, or a desktop computer. The terminal 1800 may also be referred to by other names such as user equipment, portable terminal, laptop terminal, desktop terminal, and the like.
Generally, the terminal 1800 includes: a processor 1801 and a memory 1802.
The processor 1801 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so on. The processor 1801 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 1801 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 1801 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing content required to be displayed on the display screen. In some embodiments, the processor 1801 may further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
In some embodiments, the terminal 1800 may further optionally include: a peripheral interface 1803 and at least one peripheral. The processor 1801, memory 1802, and peripheral interface 1803 may be connected by a bus or signal line. Each peripheral device may be connected to the peripheral device interface 1803 by a bus, signal line, or circuit board. Specifically, the peripheral device includes: at least one of radio frequency circuitry 1804, touch screen display 1805, camera 1806, audio circuitry 1807, positioning components 1808 and power supply 1809.
The peripherals interface 1803 can be used to connect at least one peripheral associated with I/O (Input/Output) to the processor 1801 and the memory 1802. In some embodiments, the processor 1801, memory 1802, and peripheral interface 1803 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1801, the memory 1802, and the peripheral device interface 1803 may be implemented on separate chips or circuit boards, which is not limited in this embodiment.
The Radio Frequency circuit 1804 is used for receiving and transmitting RF (Radio Frequency) signals, also called electromagnetic signals. The radio frequency circuitry 1804 communicates with communication networks and other communication devices via electromagnetic signals. The radio frequency circuitry 1804 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuitry 1804 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and so forth. The radio frequency circuitry 1804 may communicate with other terminals via at least one wireless communication protocol. The wireless communication protocols include, but are not limited to: the world wide web, metropolitan area networks, intranets, generations of mobile communication networks (2G, 3G, 4G, and 5G), Wireless local area networks, and/or WiFi (Wireless Fidelity) networks. In some embodiments, the rf circuit 1804 may also include NFC (Near Field Communication) related circuits, which are not limited in this application.
The display screen 1805 is used to display a UI (User Interface). The UI may include graphics, text, icons, video, and any combination thereof. When the display screen 1805 is a touch display screen, the display screen 1805 also has the ability to capture touch signals on or over the surface of the display screen 1805. The touch signal may be input to the processor 1801 as a control signal for processing. At this point, the display 1805 may also be used to provide virtual buttons and/or a virtual keyboard, also referred to as soft buttons and/or a soft keyboard. In some embodiments, the display 1805 may be one, providing a front panel of the terminal 1800; in other embodiments, the number of the display screens 1805 may be at least two, and each of the display screens is disposed on a different surface of the terminal 1800 or is in a foldable design; in still other embodiments, the display 1805 may be a flexible display disposed on a curved surface or a folded surface of the terminal 1800. Even more, the display 1805 may be arranged in a non-rectangular irregular figure, i.e. a shaped screen. The Display 1805 may be made of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), or the like.
The camera assembly 1806 is used to capture images or video. Optionally, the camera assembly 1806 includes a front camera and a rear camera. Generally, a front camera is disposed at a front panel of the terminal, and a rear camera is disposed at a rear surface of the terminal. In some embodiments, the number of the rear cameras is at least two, and each rear camera is any one of a main camera, a depth-of-field camera, a wide-angle camera and a telephoto camera, so that the main camera and the depth-of-field camera are fused to realize a background blurring function, and the main camera and the wide-angle camera are fused to realize panoramic shooting and VR (Virtual Reality) shooting functions or other fusion shooting functions. In some embodiments, camera assembly 1806 may also include a flash. The flash lamp can be a monochrome temperature flash lamp or a bicolor temperature flash lamp. The double-color-temperature flash lamp is a combination of a warm-light flash lamp and a cold-light flash lamp and can be used for light compensation under different color temperatures.
The audio circuitry 1807 may include a microphone and a speaker. The microphone is used for collecting sound waves of a user and the environment, converting the sound waves into electric signals, and inputting the electric signals to the processor 1801 for processing or inputting the electric signals to the radio frequency circuit 1804 to achieve voice communication. The microphones may be provided in a plurality, respectively, at different positions of the terminal 1800 for the purpose of stereo sound collection or noise reduction. The microphone may also be an array microphone or an omni-directional acquisition microphone. The speaker is used to convert electrical signals from the processor 1801 or the radio frequency circuitry 1804 to sound waves. The loudspeaker can be a traditional film loudspeaker or a piezoelectric ceramic loudspeaker. When the speaker is a piezoelectric ceramic speaker, the speaker can be used for purposes such as converting an electric signal into a sound wave audible to a human being, or converting an electric signal into a sound wave inaudible to a human being to measure a distance. In some embodiments, audio circuitry 1807 may also include a headphone jack.
The positioning component 1808 is utilized to locate a current geographic Location of the terminal 1800 for purposes of navigation or LBS (Location Based Service). The Positioning component 1808 may be a Positioning component based on a Global Positioning System (GPS) in the united states, a beidou System in china, or a galileo System in russia.
The power supply 1809 is used to power various components within the terminal 1800. The power supply 1809 may be ac, dc, disposable or rechargeable. When the power supply 1809 includes a rechargeable battery, the rechargeable battery may be a wired rechargeable battery or a wireless rechargeable battery. The wired rechargeable battery is a battery charged through a wired line, and the wireless rechargeable battery is a battery charged through a wireless coil. The rechargeable battery may also be used to support fast charge technology.
In some embodiments, the terminal 1800 also includes one or more sensors 1810. The one or more sensors 1810 include, but are not limited to: acceleration sensor 1811, gyro sensor 1812, pressure sensor 1813, fingerprint sensor 1814, optical sensor 1815, and proximity sensor 1816.
The acceleration sensor 1811 may detect the magnitude of acceleration on three coordinate axes of a coordinate system established with the terminal 1800. For example, the acceleration sensor 1811 may be used to detect components of gravitational acceleration in three coordinate axes. The processor 1801 may control the touch display 1805 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 1811. The acceleration sensor 1811 may also be used for acquisition of motion data of a game or a user.
The gyro sensor 1812 may detect a body direction and a rotation angle of the terminal 1800, and the gyro sensor 1812 may cooperate with the acceleration sensor 1811 to collect a 3D motion of the user on the terminal 1800. The processor 1801 may implement the following functions according to the data collected by the gyro sensor 1812: motion sensing (such as changing the UI according to a user's tilting operation), image stabilization at the time of photographing, game control, and inertial navigation.
The pressure sensors 1813 may be disposed on a side bezel of the terminal 1800 and/or on a lower layer of the touch display 1805. When the pressure sensor 1813 is disposed on a side frame of the terminal 1800, a user's grip signal on the terminal 1800 can be detected, and the processor 1801 performs left-right hand recognition or shortcut operation according to the grip signal collected by the pressure sensor 1813. When the pressure sensor 1813 is disposed at the lower layer of the touch display screen 1805, the processor 1801 controls the operability control on the UI interface according to the pressure operation of the user on the touch display screen 1805. The operability control comprises at least one of a button control, a scroll bar control, an icon control, and a menu control.
The fingerprint sensor 1814 is used to collect the fingerprint of the user, and the processor 1801 identifies the user according to the fingerprint collected by the fingerprint sensor 1814, or the fingerprint sensor 1814 identifies the user according to the collected fingerprint. Upon recognizing that the user's identity is a trusted identity, the processor 1801 authorizes the user to perform relevant sensitive operations, including unlocking a screen, viewing encrypted information, downloading software, paying, and changing settings, etc. The fingerprint sensor 1814 may be disposed on the front, back, or side of the terminal 1800. When a physical key or vendor Logo is provided on the terminal 1800, the fingerprint sensor 1814 may be integrated with the physical key or vendor Logo.
The optical sensor 1815 is used to collect the ambient light intensity. In one embodiment, the processor 1801 may control the display brightness of the touch display 1805 based on the ambient light intensity collected by the optical sensor 1815. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 1805 is increased; when the ambient light intensity is low, the display brightness of the touch display 1805 is turned down. In another embodiment, the processor 1801 may also dynamically adjust the shooting parameters of the camera assembly 1806 according to the intensity of the ambient light collected by the optical sensor 1815.
A proximity sensor 1816, also known as a distance sensor, is typically provided on the front panel of the terminal 1800. The proximity sensor 1816 is used to collect the distance between the user and the front surface of the terminal 1800. In one embodiment, when the proximity sensor 1816 detects that the distance between the user and the front surface of the terminal 1800 gradually decreases, the processor 1801 controls the touch display 1805 to switch from the bright screen state to the dark screen state; when the proximity sensor 1816 detects that the distance between the user and the front surface of the terminal 1800 becomes gradually larger, the processor 1801 controls the touch display 1805 to switch from the breath screen state to the bright screen state.
Those skilled in the art will appreciate that the configuration shown in fig. 7 is not intended to be limiting of terminal 1800 and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims (10)
1. A method of data conversion, the method comprising:
performing recursive sequencing according to the divisor group type constituent elements contained in each type of target input protocol and the divisor group type constituent elements contained in the corresponding type of target output protocol to generate a unique protocol identifier; the protocol identification and a corresponding mapping relation template between the corresponding target input protocol and the corresponding target output protocol are subjected to associated storage, wherein the types of the target input protocols comprise a plurality of types, and the types of the target output protocols comprise a plurality of types;
acquiring first data based on a target input protocol, and generating a protocol identifier in real time according to the type of the target input protocol of the acquired first data and the determined type of the target output protocol;
acquiring a corresponding mapping relation template according to the protocol identifier generated in real time, wherein the mapping relation template comprises a first mapping relation between the structural elements of the target input protocol and the structural elements of the target output protocol, and a second mapping relation between the association relation between the structural elements of the target input protocol and the association relation between the structural elements of the target output protocol;
and generating second data based on the target output protocol according to the first data, the first mapping relation and the second mapping relation.
2. The method of claim 1, wherein generating second data based on a target output protocol according to the first data, the first mapping relationship, and the second mapping relationship comprises:
determining the constituent elements contained in the target output protocol according to the constituent elements contained in the target input protocol and the first mapping relation;
constructing an incidence relation among the components of the target output protocol according to the second mapping relation and the incidence relation among the components of the target input protocol;
generating data included in each component of the target output protocol according to the data included in each component of the target input protocol;
outputting the second data based on the target output protocol.
3. The method of claim 2, further comprising: acquiring a node tree corresponding to the target input protocol, wherein each component of the target input protocol corresponds to a node in the node tree, and the association relationship among the components of the target input protocol is specifically the association relationship among the nodes in the node tree;
and constructing a node tree corresponding to the target output protocol according to the node tree corresponding to the target input protocol.
4. The method according to any one of claims 1-3, wherein after the obtaining the first data based on the target input protocol, further comprising:
determining the format of the first data, and converting the format of the first data into a preset format if the format of the first data is not the preset format.
5. An apparatus for data conversion, the apparatus comprising:
the generating module is used for carrying out recursive ordering according to the divisor group type constituent elements contained in each type of target input protocol and the divisor group type constituent elements contained in the corresponding type of target output protocol to generate a unique protocol identifier, wherein the types of the target input protocols comprise a plurality of types, and the types of the target output protocols comprise a plurality of types;
the storage module is used for performing associated storage on the protocol identification and a corresponding mapping relation template between the corresponding target input protocol and the corresponding target output protocol;
the acquisition module is used for acquiring first data based on a target input protocol;
the generation module is further used for generating a protocol identifier in real time according to the type of the target input protocol of the acquired first data and the determined type of the target output protocol;
the obtaining module is further configured to obtain a corresponding mapping relation template according to the protocol identifier generated in real time, where the mapping relation template includes a first mapping relation between constituent elements of a target input protocol and constituent elements of a target output protocol, and a second mapping relation between an association relation between constituent elements of the target input protocol and an association relation between constituent elements of the target output protocol;
the generating module is further configured to generate second data based on a target output protocol according to the first data, the first mapping relationship and the second mapping relationship.
6. The apparatus of claim 5, wherein the generating means is configured to:
determining the constituent elements contained in the target output protocol according to the constituent elements contained in the target input protocol and the first mapping relation;
constructing an incidence relation among the components of the target output protocol according to the second mapping relation and the incidence relation among the components of the target input protocol;
generating data included in each component of the target output protocol according to the data included in each component of the target input protocol;
outputting the second data based on the target output protocol.
7. The apparatus according to claim 6, wherein the obtaining module is further configured to obtain a node tree corresponding to the target input protocol, where each component of the target input protocol corresponds to a node in the node tree, and an association relationship between components of the target input protocol is specifically an association relationship between nodes in the node tree;
the device further comprises:
and the establishing module is used for establishing the node tree corresponding to the target output protocol according to the node tree corresponding to the target input protocol.
8. The apparatus of any of claims 5-7, further comprising:
and the conversion module is used for determining the format of the first data, and converting the format of the first data into the preset format if the format of the first data is not the preset format.
9. A terminal, characterized in that it comprises a processor and a memory, in which at least one instruction, at least one program, set of codes or set of instructions is stored, which is loaded and executed by the processor to implement the method of data conversion according to any of claims 1-4.
10. A computer readable storage medium having stored therein at least one instruction, at least one program, a set of codes, or a set of instructions, which is loaded and executed by a processor to implement the method of data conversion according to any one of claims 1 to 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811498079.XA CN111294320B (en) | 2018-12-07 | 2018-12-07 | Data conversion method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811498079.XA CN111294320B (en) | 2018-12-07 | 2018-12-07 | Data conversion method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111294320A CN111294320A (en) | 2020-06-16 |
CN111294320B true CN111294320B (en) | 2022-08-16 |
Family
ID=71020597
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811498079.XA Active CN111294320B (en) | 2018-12-07 | 2018-12-07 | Data conversion method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111294320B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113742407B (en) * | 2021-08-31 | 2024-04-30 | 浙江惠瀜网络科技有限公司 | Data conversion method and device |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102622419A (en) * | 2012-02-22 | 2012-08-01 | 中国人民解放军92859部队 | Conversion method of DNC (Digital Nautical Chart) and ENC (Electronic Nautical Chart) data models |
CN104639507A (en) * | 2013-11-13 | 2015-05-20 | 中国科学院声学研究所 | Loading protocol packet data transmission method and system among heterogeneous networks |
CN107172012A (en) * | 2017-04-18 | 2017-09-15 | 北京思特奇信息技术股份有限公司 | A kind of message format conversion method and system |
CN107222461A (en) * | 2017-05-04 | 2017-09-29 | 中国联合网络通信集团有限公司 | Communication processing method and device |
CN107306263A (en) * | 2016-04-21 | 2017-10-31 | 杭州海康威视系统技术有限公司 | A kind of method for converting protocol, platform and protocol conversion gateway |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105308927B (en) * | 2014-05-30 | 2019-03-19 | 华为技术有限公司 | Message editing processing method and relevant device |
CN108040051A (en) * | 2017-12-12 | 2018-05-15 | 开放物联(北京)科技发展有限公司 | A kind of configurable things-internet gateway method for converting protocol |
CN108460002A (en) * | 2017-12-29 | 2018-08-28 | 中国平安财产保险股份有限公司 | Affiliate's automatic butt method, apparatus, equipment and storage medium |
-
2018
- 2018-12-07 CN CN201811498079.XA patent/CN111294320B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102622419A (en) * | 2012-02-22 | 2012-08-01 | 中国人民解放军92859部队 | Conversion method of DNC (Digital Nautical Chart) and ENC (Electronic Nautical Chart) data models |
CN104639507A (en) * | 2013-11-13 | 2015-05-20 | 中国科学院声学研究所 | Loading protocol packet data transmission method and system among heterogeneous networks |
CN107306263A (en) * | 2016-04-21 | 2017-10-31 | 杭州海康威视系统技术有限公司 | A kind of method for converting protocol, platform and protocol conversion gateway |
CN107172012A (en) * | 2017-04-18 | 2017-09-15 | 北京思特奇信息技术股份有限公司 | A kind of message format conversion method and system |
CN107222461A (en) * | 2017-05-04 | 2017-09-29 | 中国联合网络通信集团有限公司 | Communication processing method and device |
Also Published As
Publication number | Publication date |
---|---|
CN111294320A (en) | 2020-06-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107885533B (en) | Method and device for managing component codes | |
CN110059685B (en) | Character area detection method, device and storage medium | |
CN110262788B (en) | Page configuration information determination method and device, computer equipment and storage medium | |
CN110321126B (en) | Method and device for generating page code | |
CN112000331A (en) | Page rendering method and device, electronic equipment and storage medium | |
CN110839128B (en) | Photographing behavior detection method and device and storage medium | |
CN108717365B (en) | Method and device for executing function in application program | |
CN111127509A (en) | Target tracking method, device and computer readable storage medium | |
CN111949680A (en) | Data processing method and device, computer equipment and storage medium | |
CN110543350A (en) | Method and device for generating page component | |
CN113467663B (en) | Interface configuration method, device, computer equipment and medium | |
CN111737100A (en) | Data acquisition method, device, equipment and storage medium | |
CN112052354A (en) | Video recommendation method, video display method and device and computer equipment | |
CN111459466B (en) | Code generation method, device, equipment and storage medium | |
CN113190362A (en) | Service calling method and device, computer equipment and storage medium | |
CN112257006A (en) | Page information configuration method, device, equipment and computer readable storage medium | |
CN109783176B (en) | Page switching method and device | |
CN111192072A (en) | User grouping method and device and storage medium | |
CN110569064B (en) | Interface identifier generation method, device, equipment and storage medium | |
CN111294320B (en) | Data conversion method and device | |
CN109033473B (en) | Picture sharing method and device and computer readable storage medium | |
CN110045999B (en) | Method, device, terminal and storage medium for drawing assembly | |
CN113268234A (en) | Page generation method, device, terminal and storage medium | |
CN112416356A (en) | JSON character string processing method, device, equipment and storage medium | |
CN110851435B (en) | Data storage method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |