CN115495082A - TLV format data automatic conversion method and related equipment - Google Patents

TLV format data automatic conversion method and related equipment Download PDF

Info

Publication number
CN115495082A
CN115495082A CN202211452351.7A CN202211452351A CN115495082A CN 115495082 A CN115495082 A CN 115495082A CN 202211452351 A CN202211452351 A CN 202211452351A CN 115495082 A CN115495082 A CN 115495082A
Authority
CN
China
Prior art keywords
format data
converted
tlv
data
tlv format
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.)
Granted
Application number
CN202211452351.7A
Other languages
Chinese (zh)
Other versions
CN115495082B (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 Yuantek Technology Co ltd
Original Assignee
Beijing Yuantek 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 Yuantek Technology Co ltd filed Critical Beijing Yuantek Technology Co ltd
Priority to CN202211452351.7A priority Critical patent/CN115495082B/en
Publication of CN115495082A publication Critical patent/CN115495082A/en
Application granted granted Critical
Publication of CN115495082B publication Critical patent/CN115495082B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code

Abstract

The application provides a TLV format data automatic conversion method and related equipment. The method comprises the following steps: creating a JSON format data; reading the length of first TLV format data to be converted to obtain a first total length; when the first total length is not less than the inherent length of the type of the first TLV format data to be converted and the TLV format data to be converted is not nested data, analyzing the first TLV format data to be converted to obtain K/V format data and second TLV format data to be converted, and storing the K/V format data into JSON format data; judging whether a second total length of the second TLV format data to be converted is zero; and responding to the fact that the second total length is zero and the conversion of the first TLV format data to be converted is finished, returning JSON format data, and completing the automatic conversion of the first TLV format data to be converted. According to the embodiment of the application, the full-automatic conversion of the TLV format data is realized by optimizing the flow of the configuration file, codes do not need to be written in the conversion process, program errors cannot be introduced, and the cost is low.

Description

TLV format data automatic conversion method and related equipment
Technical Field
The present application relates to the field of data format conversion technologies, and in particular, to an automatic TLV format data conversion method and a related device.
Background
At present, the analysis and the conversion of TLV format data are generally completed semi-automatically by writing format codes of specific nested TLVs, the automatic conversion of JSON format can be completed only by manually writing codes and configuring the TLV format, the problems that newly written codes need to be re-developed and tested exist, and if the test is insufficient, software errors possibly exist, and the development cost is increased.
Disclosure of Invention
In view of the above, an object of the present application is to provide a method for automatically converting TLV format data and a related device.
Based on the above purpose, the present application provides an automatic TLV format data conversion method, including:
creating a JSON format data in a preset configuration file;
reading the length of first TLV format data to be converted to obtain a first total length;
judging whether the first TLV format data to be converted is nested data or not in response to the fact that the first total length is not smaller than the inherent length of the type of the first TLV format data to be converted;
responding to the fact that the first TLV format data to be converted is not nested data, analyzing the first TLV format data to be converted to obtain K/V format data and second TLV format data to be converted, and storing the K/V format data into the JSON format data;
judging whether a second total length of the second TLV format data to be converted is zero or not;
responding to zero of the second total length, and judging whether the first TLV format data to be converted is converted to be finished;
and responding to the end of the conversion of the first TLV format data to be converted, returning the JSON format data, and completing the automatic conversion of the first TLV format data to be converted.
In a possible implementation manner, the parsing the first to-be-converted TLV-formatted data in response to the first to-be-converted TLV-formatted data not being nested data includes:
and in response to the first to-be-converted TLV format data not being nested data, based on the first to-be-converted TLV format data, calling a corresponding type parser to parse the first to-be-converted TLV format data with the inherent length.
In one possible implementation, the method further includes:
in response to the fact that the first TLV format data to be converted is nested data, taking the nested data in the first TLV format data to be converted as third TLV format data to be converted, and creating sub JSON format data;
acquiring the length of the third TLV format data to be converted to obtain a third total length, correcting the first total length to the third total length, analyzing the third TLV format data to be converted, and storing the analyzed data into the sub JSON format data;
responding to the end of the analysis of the third TLV format data to be converted, and obtaining fourth TLV format data to be converted according to the first TLV format data to be converted and the third TLV format data to be converted; the length of the fourth TLV format data to be converted is a fourth total length;
responding to the fourth total length being zero, combining the JSON format data with the sub JSON format data to obtain first complete JSON format data;
and returning the first complete JSON format data to complete the automatic conversion of the first TLV format data to be converted.
In one possible implementation, the method further includes:
in response to that the fourth total length is not zero, correcting the first total length to the fourth total length, analyzing the fourth TLV format data to be converted, and storing the analyzed data into the JSON format data;
responding to the end of the analysis of the fourth TLV format data to be converted, and combining the JSON format data with the sub JSON format data to obtain second complete JSON format data;
and returning the second complete JSON format data to complete the automatic conversion of the first TLV format data to be converted.
In one possible implementation, the method further includes:
generating a configuration file to be confirmed based on the acquired TLV format data item to be converted;
analyzing a preset TLV format data sample to obtain a sample result to be confirmed based on the configuration file to be confirmed;
judging whether the sample result to be confirmed is the same as a preset true sample result or not;
and in response to that the sample result to be confirmed is the same as a preset true sample result, taking the configuration file to be confirmed as the preset configuration file.
In one possible implementation, the method further includes:
stopping the conversion of the first to-be-converted TLV-formatted data in response to the first total length being less than the inherent length of the type of the first to-be-converted TLV-formatted data.
In one possible implementation, the method further includes:
judging whether the preset configuration file format is correct or not;
and in response to the incorrect preset configuration file format, reporting an error and ending the process.
Based on the same inventive concept, the embodiment of the present application further provides an automatic TLV format data conversion device, including:
the system comprises a creating module, a judging module and a judging module, wherein the creating module is configured to create a JSON format data in a preset configuration file;
the reading module is configured to read the length of the first TLV format data to be converted to obtain a first total length;
a judging module configured to judge whether the first to-be-converted TLV-formatted data is nested data in response to the first total length not being less than the inherent length of the type of the first to-be-converted TLV data;
the analysis module is configured to respond that the first TLV format data to be converted is not nested data, analyze the first TLV format data to be converted to obtain K/V format data and second TLV format data to be converted, and store the K/V format data into the JSON format data;
a judging module configured to judge whether a second total length of the second to-be-converted TLV-formatted data is zero;
a judging module configured to judge whether the first to-be-converted TLV format data is converted to be finished or not in response to the second total length being zero;
and the result returning module is configured to respond to the end of the conversion of the first TLV format data to be converted, return the JSON format data and complete the automatic conversion of the first TLV format data to be converted.
Based on the same inventive concept, an embodiment of the present application further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the method for automatically converting TLV format data according to any one of the above items.
Based on the same inventive concept, embodiments of the present application further provide a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute any one of the above-mentioned TLV format data automatic conversion methods.
As can be seen from the above, according to the TLV format data automatic conversion method and the related device provided by the present application, a JSON format data is created in a preset configuration file; reading the length of first TLV format data to be converted to obtain a first total length; judging whether the first TLV format data to be converted is nested data or not in response to the fact that the first total length is not smaller than the inherent length of the type of the first TLV format data to be converted; responding to the fact that the first TLV format data to be converted is not nested data, analyzing the first TLV format data to be converted to obtain K/V format data and second TLV format data to be converted, and storing the K/V format data into the JSON format data; judging whether a second total length of the second TLV format data to be converted is zero or not; responding to zero of the second total length, and judging whether the first TLV format data to be converted is converted to be finished; and responding to the end of the conversion of the first TLV format data to be converted, returning the JSON format data, and completing the automatic conversion of the first TLV format data to be converted. According to the embodiment of the application, the TLV format data can be automatically converted on the premise of not manually compiling codes by optimizing the flow in the configuration file, software errors cannot be introduced, and the research and development cost is effectively reduced.
Drawings
In order to more clearly illustrate the technical solutions in the present application or the related art, the drawings needed to be used in the description of the embodiments or the related art will be briefly introduced below, and it is obvious that the drawings in the following description are only embodiments of the present application, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flowchart of an automatic TLV format data conversion method according to an embodiment of the present application;
FIG. 2 is a flowchart of generating a configuration file according to an embodiment of the present application;
FIG. 3 is a schematic diagram illustrating an automatic conversion of TLV formatted data according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an automatic TLV format data conversion device according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described in detail below with reference to specific embodiments and the accompanying drawings.
It should be noted that technical terms or scientific terms used in the embodiments of the present application should have a general meaning as understood by those having ordinary skill in the art to which the present application belongs, unless otherwise defined. The use of "first," "second," and similar terms in the embodiments of the present application do not denote any order, quantity, or importance, but rather the terms are used to distinguish one element from another. The word "comprising" or "comprises", and the like, means that the element or item listed before the word covers the element or item listed after the word and its equivalents, but does not exclude other elements or items. The terms "connected" or "coupled" and the like are not restricted to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "upper", "lower", "left", "right", and the like are used merely to indicate relative positional relationships, and when the absolute position of the object being described is changed, the relative positional relationships may also be changed accordingly.
As described in the background section, the parsing and conversion of TLV format data in the related art are usually performed semi-automatically by writing format codes of specific nested TLVs, and still the automatic conversion of JSON format can be completed by manually writing codes and configuring TLVs, which has the problem that newly written codes need to be re-developed and tested, and if the test is not sufficient, software errors may still exist, resulting in an increase in development cost.
In view of the above, the embodiment of the present application provides an automatic TLV format data conversion method, which creates a JSON format data in a preset configuration file; reading the length of first TLV format data to be converted to obtain a first total length; judging whether the first TLV format data to be converted is nested data or not in response to the fact that the first total length is not smaller than the inherent length of the type of the first TLV format data to be converted; responding to the fact that the first TLV format data to be converted is not nested data, analyzing the first TLV format data to be converted to obtain K/V format data and second TLV format data to be converted, and storing the K/V format data into the JSON format data; judging whether a second total length of the second TLV format data to be converted is zero or not; responding to zero of the second total length, and judging whether the first TLV format data to be converted is converted to be finished; and responding to the end of the conversion of the first TLV format data to be converted, returning the JSON format data, and completing the automatic conversion of the first TLV format data to be converted. The full-automatic conversion of TLV format data is realized by optimizing the flow of the configuration file, no code is required to be written in the conversion process, no program error is introduced, and the research and development cost is effectively reduced.
Hereinafter, the technical means of the embodiments of the present application will be described in detail by specific examples.
Referring to fig. 1, an automatic TLV format data conversion method according to an embodiment of the present application includes the following steps:
step S101, creating a JSON format data in a preset configuration file;
step S102, reading the length of first TLV format data to be converted to obtain a first total length;
step S103, in response to that the first total length is not less than the inherent length of the type of the first TLV format data to be converted, judging whether the first TLV format data to be converted is nested data;
step S104, responding to the fact that the first TLV format data to be converted is not nested data, analyzing the first TLV format data to be converted to obtain K/V format data and second TLV format data to be converted, and storing the K/V format data into the JSON format data;
step S105, judging whether a second total length of the second TLV format data to be converted is zero;
step S106, responding to the second total length being zero, and judging whether the first TLV format data to be converted is converted to be finished;
and step S107, responding to the end of the conversion of the first TLV format data to be converted, returning the JSON format data, and completing the automatic conversion of the first TLV format data to be converted.
For high-bandwidth and high-performance mass data processing devices, generally to improve the performance and transmission efficiency of programs, TLV in binary format is a common data storage and transmission format, T represents a value type and a type code, and typical basic types include: the method comprises the steps of number, character string and binary system, wherein L represents the length of a binary value, V represents the content of the binary value, type coding is TLV which can define more combination types more flexibly, can be a basic type or a composite TLV type, the coding efficiency and transmission bandwidth are saved by binary transmission, but the subsequent analysis by using a big data storage and analysis platform is not facilitated, usually, the big data storage and analysis platform adopts a K/V structure, K represents the meaning of a data name, V represents a numerical value, and JSON is used as a data interaction format, so that the JSON format conversion needs to be carried out on the TLV, data is converted into nested JSON in a K/V form and is stored into the big data storage platform or a relational database by other ETL tools, and the subsequent analysis and mining of the data are facilitated.
For step S101, a configuration file needs to be generated first, and in a possible embodiment, refer to fig. 2, which is a flowchart of generating the configuration file according to the embodiment of the present application.
The following embodiments are illustrated based on the TLV management platform.
As can be seen from fig. 2, TLV project management is initiated first, TLV data item management is then entered, a JSON configuration file for parsing TLVs is further generated, then result verification is performed in JSON parsing result automatic verification by using data samples in TLV binary data sample management, if 100% of data samples pass through the JSON configuration file, the configuration file is directly issued, and if not, the data samples return to TLV data item management again.
Specifically, TLV format data analysis management of the TLV format data items to be converted is initiated through the TLV management platform.
And then, managing the TLV data items based on the acquired TLV format data items to be converted. TLV data items are added, deleted and modified through a TLV management platform, TLVs can be different in type and number according to the data analysis requirements of different items, and each TLV item comprises: chinese name, english name, comments, english Key name of JSON, data type coding, data type, length, and data type converted into JSON, chinese name and english name are used for translating and managing english Key name of JSON, usually for short explanatory text displayed on the interface, comments are used for describing the role of the TLV item in detail, english Key name of JSON is used for storing Key name of JSON (must be legal JSON english Key), and data types include: byte, short, integer, float, double, date, ip, string, binary, TLV, data type encoding is usually a number that occupies 1 byte to 4 bytes of storage space, the length represents the length of data, and the data type converted into JSON is used for flexible conversion between data, and may be configured without or as an effective format conversion.
Further, according to the TLV format data item management, a corresponding configuration file to be confirmed is generated.
Meanwhile, the platform is also provided with a TLV binary data sample management module which is used for managing test data samples in TLV format data analysis items and verifying whether the finally analyzed JSON format is correct, and the method comprises the following steps: the method comprises original binary TLV format data and corresponding JSON data samples, wherein the original binary TLV format data is a section of complete TLV format binary data, and the JSON format data samples are JSON format data results after TLV format analysis. Analyzing a preset TLV format data sample to obtain a sample result to be confirmed based on the configuration file to be confirmed, further judging whether the sample result to be confirmed is the same as a preset true sample result, and taking the configuration file to be confirmed as the preset configuration file in response to the sample result to be confirmed being the same as the preset true sample result. And if not, returning to the TLV data item management department to process the code so as to facilitate the next round of configuration file generation.
Further, after the preset configuration file is generated, the TLV format data is automatically converted by using the configuration file.
Referring to fig. 3, a schematic diagram of TLV format data automatic conversion according to an embodiment of the present application is shown. The whole process comprises the steps of analyzing a preset configuration file, judging whether the format of the preset configuration file is correct or not, responding to the fact that the format of the preset configuration file is incorrect, reporting an error and ending a process, if the preset configuration file is correct, creating JSON format data, reading binary TLV format data, acquiring the length of the TLV format data, judging whether the completion is completed or not, if the completion is completed, judging whether the nested TLV format is adopted or not, if the nested TLV format is adopted, adjusting the length of the residual TLV format data, further, continuously reading the residual binary TLV format data, if the nested TLV format is not adopted, directly returning the complete JSON format data, judging whether residual data exist or not, if the residual data exist, creating a JSON format data, repeating the steps, and if the residual data do not exist, completing the TLV format data analysis task. Further, if the judgment is not completed, judging whether the TLV format data are matched, if not, stopping the current TLV format data analysis, if the TLV format data are matched, judging whether the TLV format data are nested TLV format data, and if the TLV format data are nested TLV format data, creating a piece of sub JSON format data and further reading the binary TLV format data in the nesting. If the data is not the nested TLV format data, automatically calling an analyzer according to the type of the TLV format data, analyzing the TLV format data, storing the analyzed K/V format data into the JSON format data, then reading the rest binary TLV data, and repeating the subsequent steps to judge.
Specifically, for example, the TLV-formatted data with a length of 100, where 21 to 60 are nested data, and the inherent length of the TLV-formatted data is 20, a JSON data is first created, and then the length of the first TLV-formatted data to be converted is read, so as to obtain a first total length of 100.
Further, it is determined whether the first total length of the first to-be-converted TLV format data is zero, and obviously, in this embodiment, the first total length is now 100, when the first total length is not zero, the first total length and the size of the inherent length of the type of the first to-be-converted TLV format data are determined, and in response to that the first total length is not less than the inherent length of the type of the first to-be-converted TLV format data, it is determined whether the first to-be-converted TLV format data is the nested data.
In this embodiment, the inherent length is 20, the first total length is 100, and the first total length is greater than the inherent length, so that the TLV-formatted data of the inherent length in the first TLV-formatted data to be converted can be intercepted. It should be noted that, in another feasible embodiment, the first total length of the first to-be-converted TLV format data is 18, and at this time, it can be found that, when the first total length is smaller than the inherent length of the type of the first to-be-converted TLV format data, the analysis process of the current TLV format data is directly stopped at this time, because the above-mentioned situation does not occur in the normal TLV format data, and the length of the TLV format data is an integral multiple of the inherent length, if the above-mentioned situation occurs, it is described that the current TLV format data has a problem, and therefore, the analysis process of the current TLV format data needs to be stopped in time, and after the TLV format data is normal, the analysis is performed again.
Further, it is necessary to determine whether the TLV format data with the inherent length is nested data, in this embodiment, 0 to 20 are normal data, and therefore, the determination result is that the TLV format data is not nested data, and in response to that the first TLV format data to be converted is not nested data, the first TLV format data to be converted is analyzed, in this embodiment, a corresponding type of analyzer may be invoked to analyze the first TLV format data with the inherent length.
And after the analysis is finished, K/V format data and second TLV format data to be converted can be obtained, and the K/V format data is stored into the JSON format data.
And the K/V format data is obtained after the TLV format data with fixed length in the first TLV format data to be converted is converted, and is stored into JSON format data which is created at the beginning.
The second TLV format data to be converted is the first TLV format data to be converted, and after the analyzed TLV format data with the inherent length is removed, the second TLV format data to be converted can be obtained, and in this embodiment, the second total length of the second TLV format data to be converted is 80.
Further, it is determined whether the second total length of the second TLV-format data to be converted is zero, and in this embodiment, the second total length of the second TLV-format data to be converted is 80, so that it is not zero. At this time, the remaining binary TLV data and the total length thereof are continuously read, the binary TLV data read at this time is a part 21-100 of the first TLV format data to be converted, further, we can know that 21-60 are nested data, the nested data is used as a third TLV format data to be converted at this time, and the third total length thereof is obtained, in this embodiment, it can be known that, when the first TLV format data to be converted is determined subsequently, will be judged as nested data, at this time, the embodiment takes the nested data in the first TLV format data to be converted as the third TLV format data to be converted, and creates a piece of JSON format data, after the sub JSON formatted data is created, the first total length is corrected to a third total length of 40, at which point the TLV formatted data is read again, when the first total length is corrected to the third total length 40, the data read at this time becomes 21-60 in the first TLV format data to be converted, and similarly, it is determined whether the third total length is 0, 40 at this time, not 0, therefore, the next step is to determine whether the third total length is not less than the inherent length, 40 is greater than 20, and the determination result is not less, at this time, intercepting the third TLV format data to be converted according to the inherent length of the third TLV format data to obtain 21-40 data, further judging whether the 21-40 data is nested data, in this embodiment, if the data is not nested data, the data segment is parsed according to the foregoing method to obtain corresponding K/V data, and it should be noted that the K/V data obtained at this time needs to be stored in the sub JSON format data created in the foregoing process.
Further, when the 21-40 analysis is finished, continuously reading third to-be-converted TLV format data, which is 41-60 data in the first to-be-converted TLV format data, similarly, analyzing the data in the above step, which is similar to the above step and is not repeated herein, when the 41-60 data is analyzed, performing a new round of data reading, which is zero in length and is determined as zero when the third total length is determined, and determining whether the conversion of the first to-be-converted TLV format data is finished in response to the fact that the third total length is zero, obviously, the first to-be-converted TLV format data is not converted by 61-100, so that the determination result is not converted, and at this time, obtaining fourth to-be-converted TLV format data according to the first to-be-converted TLV format data and the third to-be-converted TLV format data; the length of the fourth TLV format data to be converted is a fourth total length. The fourth TLV format data to be converted is obtained according to the first TLV format data to be converted and the third TLV format data to be converted, specifically, the third TLV format data to be converted in the first TLV format data to be converted is removed in length to obtain the fourth TLV format data to be converted, in this embodiment, the fourth TLV format data to be converted is 61-100 data, the 61-100 data is normal data, and does not include nested data, further, the first total length is corrected to the fourth total length, the fourth TLV format data to be converted is analyzed, and the analyzed data is stored in the JSON format data, and the analyzing process is consistent with the analyzing process of the normal data, and is not described herein again.
Further, after the 61-100 data are analyzed, the length of the TLV data is read again, the read length is zero, further, whether the conversion of the first TLV format data to be converted is finished or not is judged, obviously, the conversion is finished, and then the JSON format data and the sub JSON format data are combined to obtain second complete JSON format data.
And further, judging whether residual data are not analyzed completely, if so, creating JSON format data again, and if not, directly completing the analysis process of the TLV format data.
According to the embodiments, the method for automatically converting the TLV format data comprises the steps of creating a JSON format data in a preset configuration file; reading the length of first TLV format data to be converted to obtain a first total length; judging whether the first TLV format data to be converted is nested data or not in response to the fact that the first total length is not smaller than the inherent length of the type of the first TLV format data to be converted; responding to the fact that the first TLV format data to be converted is not nested data, analyzing the first TLV format data to be converted to obtain K/V format data and second TLV format data to be converted, and storing the K/V format data into the JSON format data; judging whether a second total length of the second TLV format data to be converted is zero or not; in response to the second total length being zero, judging whether the first TLV format data to be converted is converted to be finished; and responding to the end of the conversion of the first TLV format data to be converted, returning the JSON format data, and completing the automatic conversion of the first TLV format data to be converted. By optimizing the flow in the configuration file, the full-automatic conversion of TLV format data can be realized on the premise of not manually compiling codes, software errors cannot be introduced, and the research and development cost is effectively reduced.
It should be noted that the method of the embodiment of the present application may be executed by a single device, such as a computer or a server. The method of the embodiment can also be applied to a distributed scene and completed by the mutual cooperation of a plurality of devices. In such a distributed scenario, one of the multiple devices may only perform one or more steps of the method of the embodiment, and the multiple devices interact with each other to complete the method.
It should be noted that the foregoing describes some embodiments of the present application. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments described above and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
Based on the same inventive concept, corresponding to any embodiment of the method, the application also provides an automatic TLV format data conversion device.
Referring to fig. 4, the TLV format data automatic conversion apparatus includes:
a creating module 41 configured to create a piece of JSON format data in a preset configuration file;
a reading module 42 configured to read the length of the first TLV format data to be converted, so as to obtain a first total length;
a judging module 43, configured to judge whether the first TLV format data to be converted is nested data in response to the first total length not being less than the inherent length of the type of the first TLV format data to be converted;
the analyzing module 44 is configured to respond that the first to-be-converted TLV format data is not nested data, analyze the first to-be-converted TLV format data to obtain K/V format data and second to-be-converted TLV format data, and store the K/V format data into the JSON data;
a judging module 43, configured to judge whether the second total length of the second TLV format data to be converted is zero;
a judging module 43, configured to, in response to that the second total length is zero, judge whether the first TLV format data to be converted is converted to end;
a result returning module 45, configured to return the JSON-format data in response to the end of the conversion of the first to-be-converted TLV-format data, and complete the automatic conversion of the first to-be-converted TLV-format data.
For convenience of description, the above devices are described as being divided into various modules by functions, and are described separately. Of course, the functionality of the various modules may be implemented in the same one or more software and/or hardware implementations as the present application.
The apparatus in the foregoing embodiment is used to implement the corresponding TLV format data automatic conversion method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiment, which are not described herein again.
Based on the same inventive concept, corresponding to the method of any embodiment described above, the present application further provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the program, the TLV format data automatic conversion method described in any embodiment above is implemented.
Fig. 5 is a schematic diagram illustrating a more specific hardware structure of an electronic device according to this embodiment, where the electronic device may include: a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050. Wherein the processor 1010, memory 1020, input/output interface 1030, and communication interface 1040 are communicatively coupled to each other within the device via bus 1050.
The processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits, and is configured to execute related programs to implement the technical solutions provided in the embodiments of the present disclosure.
The Memory 1020 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, or the like. The memory 1020 may store an operating system and other application programs, and when the technical solution provided by the embodiments of the present specification is implemented by software or firmware, the relevant program codes are stored in the memory 1020 and called to be executed by the processor 1010.
The input/output interface 1030 is used for connecting an input/output module to input and output information. The i/o module may be configured as a component within the device (not shown) or may be external to the device to provide corresponding functionality. The input devices may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices may include a display, a speaker, a vibrator, an indicator light, etc.
The communication interface 1040 is used for connecting a communication module (not shown in the drawings) to implement communication interaction between the present apparatus and other apparatuses. The communication module can realize communication in a wired mode (such as USB, network cable and the like) and also can realize communication in a wireless mode (such as mobile network, WIFI, bluetooth and the like).
Bus 1050 includes a path that transfers information between various components of the device, such as processor 1010, memory 1020, input/output interface 1030, and communication interface 1040.
It should be noted that although the above-mentioned device only shows the processor 1010, the memory 1020, the input/output interface 1030, the communication interface 1040 and the bus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, those skilled in the art will appreciate that the above-described apparatus may also include only those components necessary to implement the embodiments of the present description, and not necessarily all of the components shown in the figures.
The electronic device in the foregoing embodiment is used to implement the corresponding TLV format data automatic conversion method in any one of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiment, which are not described herein again.
Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application further provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the TLV format data automatic conversion method according to any of the above embodiments.
Computer-readable media of the present embodiments, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device.
The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the TLV format data automatic conversion method according to any of the above embodiments, and have the beneficial effects of corresponding method embodiments, which are not described herein again.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, is limited to these examples; within the context of the present application, technical features in the above embodiments or in different embodiments may also be combined, steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application described above, which are not provided in detail for the sake of brevity.
In addition, well-known power/ground connections to Integrated Circuit (IC) chips and other components may or may not be shown in the provided figures for simplicity of illustration and discussion, and so as not to obscure the embodiments of the application. Further, devices may be shown in block diagram form in order to avoid obscuring embodiments of the application, and this also takes into account the fact that specifics with respect to implementation of such block diagram devices are highly dependent upon the platform within which the embodiments of the application are to be implemented (i.e., specifics should be well within purview of one skilled in the art). Where specific details (e.g., circuits) are set forth in order to describe example embodiments of the application, it should be apparent to one skilled in the art that the embodiments of the application can be practiced without, or with variation of, these specific details. Accordingly, the description is to be regarded as illustrative instead of restrictive.
While the present application has been described in conjunction with specific embodiments thereof, many alternatives, modifications, and variations of these embodiments will be apparent to those skilled in the art in light of the foregoing description. For example, other memory architectures, such as Dynamic RAM (DRAM), may use the discussed embodiments.
The present embodiments are intended to embrace all such alternatives, modifications and variances which fall within the broad scope of the appended claims. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present application are intended to be included within the scope of the present application.

Claims (10)

1. A TLV format data automatic conversion method is characterized by comprising the following steps:
creating a JSON format data in a preset configuration file;
reading the length of first TLV format data to be converted to obtain a first total length;
judging whether the first TLV format data to be converted is nested data or not in response to the fact that the first total length is not smaller than the inherent length of the type of the first TLV format data to be converted;
responding to the fact that the first TLV format data to be converted is not nested data, analyzing the first TLV format data to be converted to obtain K/V format data and second TLV format data to be converted, and storing the K/V format data into the JSON format data;
judging whether a second total length of the second TLV format data to be converted is zero or not;
responding to zero of the second total length, and judging whether the first TLV format data to be converted is converted to be finished;
and responding to the end of the conversion of the first TLV format data to be converted, returning the JSON format data, and completing the automatic conversion of the first TLV format data to be converted.
2. The method of claim 1, wherein said parsing the first to-be-converted TLV-formatted data in response to the first to-be-converted TLV-formatted data not being nested data comprises:
and in response to the first to-be-converted TLV format data not being nested data, based on the first to-be-converted TLV format data, calling a corresponding type parser to parse the first to-be-converted TLV format data with the inherent length.
3. The method of claim 1, further comprising:
in response to the fact that the first TLV format data to be converted is nested data, taking the nested data in the first TLV format data to be converted as third TLV format data to be converted, and creating sub JSON format data;
acquiring the length of the third TLV format data to be converted to obtain a third total length, correcting the first total length to the third total length, analyzing the third TLV format data to be converted, and storing the analyzed data into the sub JSON format data;
responding to the end of the analysis of the third TLV format data to be converted, and obtaining fourth TLV format data to be converted according to the first TLV format data to be converted and the third TLV format data to be converted; the length of the fourth TLV format data to be converted is a fourth total length;
responding to the fourth total length being zero, combining the JSON format data with the sub JSON format data to obtain first complete JSON format data;
and returning the first complete JSON format data to complete the automatic conversion of the first TLV format data to be converted.
4. The method of claim 3, further comprising:
in response to that the fourth total length is not zero, correcting the first total length into the fourth total length, analyzing the fourth TLV format data to be converted, and storing the analyzed data into the JSON format data;
responding to the end of the analysis of the fourth TLV format data to be converted, and combining the JSON format data with the sub JSON format data to obtain second complete JSON format data;
and returning the second complete JSON format data to complete the automatic conversion of the first TLV format data to be converted.
5. The method of claim 1, further comprising:
generating a configuration file to be confirmed based on the acquired TLV format data item to be converted;
analyzing a preset TLV format data sample to obtain a sample result to be confirmed based on the configuration file to be confirmed;
judging whether the sample result to be confirmed is the same as a preset true sample result or not;
and in response to the fact that the sample result to be confirmed is the same as a preset true sample result, taking the configuration file to be confirmed as the preset configuration file.
6. The method of claim 1, further comprising:
stopping the conversion of the first to-be-converted TLV-formatted data in response to the first total length being less than the inherent length of the type of the first to-be-converted TLV-formatted data.
7. The method of claim 1, further comprising:
judging whether the preset configuration file format is correct or not;
and in response to the incorrect preset configuration file format, reporting an error and ending the process.
8. An apparatus for automatically converting TLV format data, comprising:
the system comprises a creating module, a judging module and a judging module, wherein the creating module is configured to create a JSON format data in a preset configuration file;
the reading module is configured to read the length of the first TLV format data to be converted to obtain a first total length;
a judging module configured to judge whether the first to-be-converted TLV-formatted data is nested data in response to the first total length not being less than the inherent length of the type of the first to-be-converted TLV-formatted data;
the analysis module is configured to respond that the first TLV format data to be converted is not nested data, analyze the first TLV format data to be converted to obtain K/V format data and second TLV format data to be converted, and store the K/V format data into the JSON format data;
a judging module configured to judge whether a second total length of the second to-be-converted TLV-formatted data is zero;
a judging module configured to judge whether the first to-be-converted TLV format data is converted to be finished or not in response to the second total length being zero;
and the result returning module is configured to respond to the end of the conversion of the first to-be-converted TLV format data, return the JSON format data and complete the automatic conversion of the first to-be-converted TLV format data.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 7 when executing the program.
10. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of any one of claims 1 to 7.
CN202211452351.7A 2022-11-21 2022-11-21 TLV format data automatic conversion method and related equipment Active CN115495082B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211452351.7A CN115495082B (en) 2022-11-21 2022-11-21 TLV format data automatic conversion method and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211452351.7A CN115495082B (en) 2022-11-21 2022-11-21 TLV format data automatic conversion method and related equipment

Publications (2)

Publication Number Publication Date
CN115495082A true CN115495082A (en) 2022-12-20
CN115495082B CN115495082B (en) 2023-03-24

Family

ID=85116228

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211452351.7A Active CN115495082B (en) 2022-11-21 2022-11-21 TLV format data automatic conversion method and related equipment

Country Status (1)

Country Link
CN (1) CN115495082B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116707806A (en) * 2023-08-09 2023-09-05 中电信量子科技有限公司 Password equipment management method and management platform

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170124166A1 (en) * 2015-10-29 2017-05-04 Ip Reservoir, Llc Dynamic Field Data Translation to Support High Performance Stream Data Processing
CN109413154A (en) * 2018-09-26 2019-03-01 平安普惠企业管理有限公司 Conversion method of data format, device, computer equipment and storage medium
CN109981651A (en) * 2019-03-27 2019-07-05 努比亚技术有限公司 Data transmission method, device, mobile terminal and readable storage medium storing program for executing
CN110222008A (en) * 2019-05-06 2019-09-10 平安国际智慧城市科技股份有限公司 A kind of conversion method of data format, system, medium and electronic equipment
CN110264648A (en) * 2019-05-10 2019-09-20 杭州米雅信息科技有限公司 Data processing method and device, automatic teller machine and data processing system
CN114337920A (en) * 2021-12-23 2022-04-12 中国农业银行股份有限公司 Code analysis method and device and electronic equipment
CN114938401A (en) * 2022-03-21 2022-08-23 北京思信飞扬信息技术股份有限公司 Configurable network protocol data analysis method and electronic equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170124166A1 (en) * 2015-10-29 2017-05-04 Ip Reservoir, Llc Dynamic Field Data Translation to Support High Performance Stream Data Processing
CN109413154A (en) * 2018-09-26 2019-03-01 平安普惠企业管理有限公司 Conversion method of data format, device, computer equipment and storage medium
CN109981651A (en) * 2019-03-27 2019-07-05 努比亚技术有限公司 Data transmission method, device, mobile terminal and readable storage medium storing program for executing
CN110222008A (en) * 2019-05-06 2019-09-10 平安国际智慧城市科技股份有限公司 A kind of conversion method of data format, system, medium and electronic equipment
CN110264648A (en) * 2019-05-10 2019-09-20 杭州米雅信息科技有限公司 Data processing method and device, automatic teller machine and data processing system
CN114337920A (en) * 2021-12-23 2022-04-12 中国农业银行股份有限公司 Code analysis method and device and electronic equipment
CN114938401A (en) * 2022-03-21 2022-08-23 北京思信飞扬信息技术股份有限公司 Configurable network protocol data analysis method and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
廖振宇: "基于软件定义网络的光传送网研究与设计", 《电子设计工程》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116707806A (en) * 2023-08-09 2023-09-05 中电信量子科技有限公司 Password equipment management method and management platform
CN116707806B (en) * 2023-08-09 2023-10-31 中电信量子科技有限公司 Password equipment management method and management platform

Also Published As

Publication number Publication date
CN115495082B (en) 2023-03-24

Similar Documents

Publication Publication Date Title
CN111428462B (en) Communication protocol template construction method and terminal equipment
CN108628748B (en) Automatic test management method and automatic test management system
CN107526676B (en) Cross-system test method and device
CN111241182A (en) Data processing method and apparatus, storage medium, and electronic apparatus
CN107451058B (en) Software development method and device
CN115495082B (en) TLV format data automatic conversion method and related equipment
CN112817866A (en) Recording playback method, device, system, computer equipment and storage medium
CN112395305A (en) SQL statement analysis method and device, electronic equipment and storage medium
CN111209736A (en) Text file analysis method and device, computer equipment and storage medium
CN110704325B (en) Data processing method and device, computer storage medium and electronic equipment
CN111078529B (en) Client writing module testing method and device and electronic equipment
CN109474822B (en) Android television multi-language automatic testing method and device
CN115391015A (en) Batch processing method and device based on test framework, electronic equipment and medium
CN112953721B (en) IPA file analysis method, IPA file analysis device, IPA file analysis equipment and storage medium
CN115033434A (en) Kernel performance theoretical value calculation method and device and storage medium
CN109062797B (en) Method and device for generating information
CN112148581A (en) Code specification checking method, device, system and storage medium
CN113742225B (en) Test data generation method, device, equipment and storage medium
CN113031959B (en) Variable replacement method, device, system and storage medium
CN112380114A (en) Automatic generation method and device for reverse test case file and electronic equipment
CN114816989A (en) Optimization method of automatic test script and related equipment
CN113704020A (en) Method and device for analyzing error field data of solid state disk
CN115861478A (en) Intelligent contract execution flow chart generation method, device, equipment and storage medium
CN115577032A (en) Method, device, terminal and storage medium for converting JSON (Java Server object notation) into SQL (structured query language)
CN113986381A (en) Data analysis method, device, equipment and storage medium

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