CN114237571A - Code data conversion method, device, equipment and medium - Google Patents

Code data conversion method, device, equipment and medium Download PDF

Info

Publication number
CN114237571A
CN114237571A CN202111535063.3A CN202111535063A CN114237571A CN 114237571 A CN114237571 A CN 114237571A CN 202111535063 A CN202111535063 A CN 202111535063A CN 114237571 A CN114237571 A CN 114237571A
Authority
CN
China
Prior art keywords
data
conversion
target
converted
formatting
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.)
Pending
Application number
CN202111535063.3A
Other languages
Chinese (zh)
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202111535063.3A priority Critical patent/CN114237571A/en
Publication of CN114237571A publication Critical patent/CN114237571A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The invention relates to the field of big data, and provides a code data conversion method, a device, equipment and a medium, which can perform preliminary verification on data before conversion, perform subsequent conversion after verification is passed, avoid executing invalid operation to cause unnecessary loss on resources and time, call corresponding components to realize targeted formatting processing on the data, improve the data conversion efficiency, have higher accuracy, improve the coverage of data conversion on code languages due to encapsulation of various formatting components, have stronger practicability, improve the neatness of pages by performing formatting processing on code data, improve the readability and reusability of codes, facilitate the code inspection, further reduce the mastering standard of a user on program languages due to conversion among various language types, and improve the user experience. In addition, the invention also relates to a block chain technology, and the target data can be stored in the block chain nodes.

Description

Code data conversion method, device, equipment and medium
Technical Field
The present invention relates to the field of big data, and in particular, to a method, an apparatus, a device, and a medium for converting code data.
Background
In the process of Web page development, the structures of the related code data are various, and because the mastering conditions of the program language of each technician are different, the displayed code data is probably not understood by the technician, so that the difficulty is caused for the technician to read the code.
In addition, in the prior art, even if the same language is used, the presented data formats can be various, the execution sequence and the functions of codes in each row are not clear, the reading speed is slow, and when a fault occurs, the fault is difficult to find due to code confusion, and the working efficiency is affected.
Disclosure of Invention
In view of the above, there is a need to provide a code data transformation method, apparatus, device and medium, which aim to solve the problem of code data format confusion in Web pages.
A code data translation method, the code data translation method comprising:
acquiring data to be converted, and generating a conversion request based on the data to be converted;
analyzing the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted;
acquiring a verification method corresponding to the initial language type, and verifying the data stored in the storage path according to the verification method;
when the data stored in the storage path passes the verification, calling a first target component corresponding to the initial language type from a pre-packaged formatting component, formatting the data to be converted by using the first target component to obtain first converted data, and displaying the first converted data;
when an instruction for transmitting the first conversion data to a target terminal is received, identifying a language type corresponding to the target terminal as a target language type;
calling a second target component corresponding to the target language type from the formatting component, and formatting the first conversion data by using the second target component to obtain second conversion data;
and recombining the second conversion data to obtain target data, and sending the target data to the target terminal.
According to a preferred embodiment of the present invention, the analyzing the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted includes:
acquiring a file header from the conversion request;
extracting configuration items in the file header;
acquiring a first label corresponding to any language type and a second label corresponding to any storage path;
extracting data from the configuration items according to the first label, and using the data as an initial language type of the data to be converted;
and extracting data from the configuration items according to the second label, and using the data as a storage path of the data to be converted.
According to a preferred embodiment of the present invention, before the first target component corresponding to the initial language type is called from the pre-packaged formatted component, the method further comprises:
acquiring a formatting component of each language type;
configuring component identification for formatting components of each language type to obtain identification of each formatting component;
acquiring a method of each formatting component, and adding the method of each formatting component into a prototype object to obtain an object corresponding to each formatting component;
and creating a constructor, and packaging the object corresponding to each formatting component according to the constructor, wherein the entry of the constructor is the identifier of each formatting component.
According to a preferred embodiment of the present invention, the formatting the data to be converted by using the first target component to obtain first converted data includes:
acquiring an identifier of the first target component;
passing an identification of the first target component as an argument into the constructor;
and executing the method of the first target assembly by using the constructor, and formatting the data to be converted to obtain the first conversion data.
According to a preferred embodiment of the present invention, the formatting the data to be converted by using the first target component to obtain first converted data further includes:
when the initial language type is the SQL type, determining the first target component as an SQL script conversion plug-in, and performing formatting processing on the data to be converted by using the SQL script conversion plug-in to obtain the first conversion data, wherein parameters of the SQL script conversion plug-in include the language type and the character reduction amount; or
And when the initial language type is the JSON type, reading the data to be converted into a character string, determining the first target assembly as a JSON formatter extension plug-in, and formatting the character string by using the JSON formatter extension plug-in to obtain the first converted data.
According to a preferred embodiment of the present invention, the displaying the first conversion data comprises:
acquiring an editor corresponding to a front-end interface;
displaying the first converted data on the editor.
According to a preferred embodiment of the present invention, when the second conversion data is recombined to obtain target data and the target data is sent to the target terminal, the method further includes:
adding check bytes in the second conversion data to obtain the target data;
and when the target data is sent to the target terminal, the target terminal is informed to verify the received data by using the check bytes.
A code data translation apparatus, the code data translation apparatus comprising:
the generating unit is used for acquiring data to be converted and generating a conversion request based on the data to be converted;
the analysis unit is used for analyzing the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted;
the verification unit is used for acquiring a verification method corresponding to the initial language type and verifying the data stored in the storage path according to the verification method;
the formatting unit is used for calling a first target component corresponding to the initial language type from a pre-packaged formatting component when the data stored in the storage path passes the verification, formatting the data to be converted by using the first target component to obtain first converted data, and displaying the first converted data;
the identification unit is used for identifying the language type corresponding to the target terminal as the target language type when receiving an instruction of transmitting the first conversion data to the target terminal;
the formatting unit is further configured to invoke a second target component corresponding to the target language type from the formatting component, and perform formatting processing on the first conversion data by using the second target component to obtain second conversion data;
and the recombination unit is used for recombining the second conversion data to obtain target data and sending the target data to the target terminal.
A computer device, the computer device comprising:
a memory storing at least one instruction; and
and the processor executes the instructions stored in the memory to realize the code data conversion method.
A computer-readable storage medium having stored therein at least one instruction for execution by a processor in a computer device to implement the code data translation method.
According to the technical scheme, the invention can obtain the data to be converted, generate the conversion request based on the data to be converted, analyze the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted, obtain the verification method corresponding to the initial language type, verify the data stored in the storage path according to the verification method, perform preliminary verification on the data before conversion, perform subsequent conversion after verification is passed, avoid performing invalid operation to cause unnecessary loss of resources and time, call a first target component corresponding to the initial language type from a pre-packaged formatting component when the data stored in the storage path passes verification, and perform formatting processing on the data to be converted by using the first target component, the method comprises the steps of obtaining first conversion data, displaying the first conversion data, calling corresponding components to achieve targeted formatting of the data, improving data conversion efficiency, being higher in accuracy, improving the coverage of data conversion to code languages due to packaging of various formatting components, being higher in practicability, identifying the language type corresponding to a target terminal as a target language type when receiving an instruction for transmitting the first conversion data to the target terminal, calling a second target component corresponding to the target language type from the formatting components, formatting the first conversion data by using the second target component to obtain second conversion data, recombining the second conversion data to obtain target data, transmitting the target data to the target terminal, and formatting the code data, the neatness of the page is improved, the readability and reusability of the codes are improved, the codes can be checked conveniently, meanwhile, the standard of mastering of the program language by a user is further reduced through conversion among multiple language types, and the user experience is improved.
Drawings
FIG. 1 is a flow chart of the preferred embodiment of the code data transformation method of the present invention.
FIG. 2 is another flow chart of the preferred embodiment of the code data transformation method of the present invention.
FIG. 3 is another flow chart of the preferred embodiment of the code data transformation method of the present invention.
FIG. 4 is a functional block diagram of a preferred embodiment of the code data conversion apparatus of the present invention.
FIG. 5 is a schematic structural diagram of a computer device for implementing a code data transformation method according to a preferred embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
FIG. 1 is a flow chart of the preferred embodiment of the code data transformation method of the present invention. The order of the steps in the flow chart may be changed and some steps may be omitted according to different needs.
The code data conversion method is applied to one or more computer devices, which are devices capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and the hardware thereof includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device may be any electronic product capable of performing human-computer interaction with a user, for example, a Personal computer, a tablet computer, a smart phone, a Personal Digital Assistant (PDA), a game machine, an interactive web Television (IPTV), an intelligent wearable device, and the like.
The computer device may also include a network device and/or a user device. The network device includes, but is not limited to, a single network server, a server group consisting of a plurality of network servers, or a Cloud Computing (Cloud Computing) based Cloud consisting of a large number of hosts or network servers.
The server may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like.
Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The Network in which the computer device is located includes, but is not limited to, the internet, a wide area Network, a metropolitan area Network, a local area Network, a Virtual Private Network (VPN), and the like.
And S10, acquiring the data to be converted, and generating a conversion request based on the data to be converted.
In this embodiment, the data to be converted may be code data of any language type, such as: SQL (Structured Query Language) statements, JSON (JavaScript Object Notation) statements, and the like.
Further, the data to be converted may be uploaded by a user, or may be uploaded by a back-end server, which is not limited in the present invention.
In at least one embodiment of the present invention, the conversion request may include, but is not limited to, one or more of the following combinations of information:
the language type of the data to be converted, the storage path of the data to be converted and the language identification of the data to be converted.
S11, analyzing the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted.
In at least one embodiment of the present invention, the parsing the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted includes:
acquiring a file header from the conversion request;
extracting configuration items in the file header;
acquiring a first label corresponding to any language type and a second label corresponding to any storage path;
extracting data from the configuration items according to the first label, and using the data as an initial language type of the data to be converted;
and extracting data from the configuration items according to the second label, and using the data as a storage path of the data to be converted.
For example: the first tag may be a language and the second tag may be an address.
In the above embodiment, the configuration of the header can facilitate the identification of the request, and the language type and the storage path are added to the configuration item of the header, so that the required information can be directly acquired from the request, and the efficiency of data processing is improved.
And S12, acquiring a verification method corresponding to the initial language type, and verifying the data stored in the storage path according to the verification method.
It can be understood that each code language has a corresponding verification method, and the verification method is mainly used for verifying the format specification of the code.
In at least one embodiment of the present invention, the obtaining a verification method corresponding to the initial language type, and verifying the data stored at the storage path according to the verification method includes:
acquiring a pre-stored checking method list, wherein the checking method list is used for storing the corresponding relation between the checking method and the language type;
querying in the verification method list by using the initial language type, and determining a verification method corresponding to the initial language type as a target verification method;
and verifying the data stored at the storage path by using the target verification method.
For example: when the initial language type is SQL, checking whether the data stored in the storage path has formats such as SELECT and the like; when the initial language type is JSON, checking whether the data stored at the storage path has a format such as key-value.
Further, when the data stored in the storage path passes the verification, it indicates that the data to be converted is not abnormal and meets the condition of data conversion; when the data stored in the storage path is not verified, it is indicated that the data to be converted is abnormal and does not meet the condition of data conversion, and subsequent conversion does not need to be executed, so that waste of redundant running resources and waste are avoided.
Through the embodiment, the data is preliminarily checked before the conversion, and after the data passes the check, the subsequent conversion is executed, so that the unnecessary loss of resources and time caused by the execution of invalid operation is avoided.
And S13, when the data stored in the storage path passes the verification, calling a first target component corresponding to the initial language type from a pre-packaged formatting component, formatting the data to be converted by using the first target component to obtain first converted data, and displaying the first converted data.
In at least one embodiment of the invention, before the first target component corresponding to the initial language type is called from the pre-packaged formatted component, the method further comprises:
acquiring a formatting component of each language type;
configuring component identification for formatting components of each language type to obtain identification of each formatting component;
acquiring a method of each formatting component, and adding the method of each formatting component into a prototype object to obtain an object corresponding to each formatting component;
and creating a constructor, and packaging the object corresponding to each formatting component according to the constructor, wherein the entry of the constructor is the identifier of each formatting component.
Through the implementation mode, formatting components of various language types can be uniformly packaged, so that global calling is facilitated.
Please refer to fig. 2, which is another flowchart of the code data transformation method according to the preferred embodiment of the present invention. Specifically, the formatting the data to be converted by using the first target component to obtain first converted data includes:
s1311, acquiring an identifier of the first target assembly;
s1312, passing the identification of the first target component as an entry into the constructor;
s1313, the constructor is used for executing the method of the first target assembly, and formatting processing is conducted on the data to be converted, so that the first conversion data is obtained.
Through the implementation mode, the corresponding components can be called to achieve targeted formatting processing of the data, the data conversion efficiency is improved, the accuracy is higher, the packaging of various formatting components also improves the coverage of data conversion on code languages, and the practicability is higher.
Please refer to fig. 3, which is another flowchart of the code data transformation method according to the preferred embodiment of the present invention. Wherein, the formatting the data to be converted by using the first target component to obtain first converted data further includes:
s1321, when the initial language type is the SQL type, determining the first target component as an SQL script conversion plug-in, and performing formatting processing on the data to be converted by using the SQL script conversion plug-in to obtain first conversion data, wherein parameters of the SQL script conversion plug-in include the language type and the character input; or
And S1322, when the initial language type is a JSON type, reading the data to be converted into a character string, determining the first target assembly as a JSON formatter extension plug-in, and formatting the character string by using the JSON formatter extension plug-in to obtain the first converted data.
The SQL script conversion plug-in can be a FormatSQL plug-in.
The JSON formatter extension plug-in can be a FormatSQL plug-in.
Through the implementation mode, the corresponding conversion assemblies are respectively called for the SQL type or the JSON type to carry out formatting processing, original disordered codes are normalized, readability of code data is improved, and identification and corresponding operation are facilitated.
In at least one embodiment of the present invention, the displaying the first conversion data comprises:
acquiring an editor corresponding to a front-end interface;
displaying the first converted data on the editor.
The editor is used for compiling codes, and relevant tasks can be executed after compiling.
Through the implementation mode, the original code data which is difficult to understand is formatted and then displayed on the editor at the front end for relevant workers to read.
And S14, when receiving an instruction of transmitting the first conversion data to a target terminal, identifying the language type corresponding to the target terminal as a target language type.
In this embodiment, the instruction may be triggered by a relevant worker, such as a developer.
For example: after the first conversion data is displayed, a developer A determines that an executive party of a next task is a terminal B by reading codes, then determines the terminal B as the target terminal, and can trigger an instruction for transmitting the first conversion data to the terminal B by clicking a designated button or voice control and the like.
In this embodiment, the target terminal corresponds to a downstream device, and refers to a recipient of the translated language, and is configured to execute a specific task and the like according to the translated code.
In this embodiment, the data conversion requirement of the target terminal may be read, or the language type of the target terminal may be read, so as to determine the language type corresponding to the target terminal.
For example: the attribute data of the target terminal can be read, and the language type corresponding to the target terminal is obtained from the attribute data and is used as the target language type.
And S15, calling a second target component corresponding to the target language type from the formatting component, and formatting the first conversion data by using the second target component to obtain second conversion data.
For example: and when the target language type is JSON and the language type of the first conversion data is SQL, the second target assembly is a plug-in capable of converting the SQL statement into the JSON statement.
Specifically, the manner of performing formatting processing on the first conversion data by using the second target component to obtain the second conversion data is similar to the manner of performing formatting processing on the data to be converted by using the first target component, which is not described herein again.
And S16, recombining the second conversion data to obtain target data, and sending the target data to the target terminal.
In the embodiment, the code data is formatted, so that the neatness of the page is improved, the readability and reusability of the code are improved, the code is convenient to check, the standard of mastering the program language by a user is further reduced through conversion among multiple language types, and the user experience is improved.
In at least one embodiment of the present invention, when the second conversion data is recombined to obtain target data and the target data is sent to the target terminal, the method further includes:
adding check bytes in the second conversion data to obtain the target data;
and when the target data is sent to the target terminal, the target terminal is informed to verify the received data by using the check bytes.
The check byte can be configured by self-definition, such as 8-bit cyclic redundancy check code.
Through the embodiment, when the converted data is transmitted to the target terminal, the target terminal can judge whether the corresponding data is successfully received according to the check bytes through the data recombination, so that the stability of data transmission is improved, and transmission errors are effectively avoided.
Of course, in other embodiments, in order to further ensure the security of data transmission, the target data may also be encrypted for transmission, which is not described herein again.
It should be noted that, in order to further improve the security of the data and avoid malicious tampering of the data, the target data block chain node is provided.
According to the technical scheme, the invention can obtain the data to be converted, generate the conversion request based on the data to be converted, analyze the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted, obtain the verification method corresponding to the initial language type, verify the data stored in the storage path according to the verification method, perform preliminary verification on the data before conversion, perform subsequent conversion after verification is passed, avoid performing invalid operation to cause unnecessary loss of resources and time, call a first target component corresponding to the initial language type from a pre-packaged formatting component when the data stored in the storage path passes verification, and perform formatting processing on the data to be converted by using the first target component, the method comprises the steps of obtaining first conversion data, displaying the first conversion data, calling corresponding components to achieve targeted formatting of the data, improving data conversion efficiency, being higher in accuracy, improving the coverage of data conversion to code languages due to packaging of various formatting components, being higher in practicability, identifying the language type corresponding to a target terminal as a target language type when receiving an instruction for transmitting the first conversion data to the target terminal, calling a second target component corresponding to the target language type from the formatting components, formatting the first conversion data by using the second target component to obtain second conversion data, recombining the second conversion data to obtain target data, transmitting the target data to the target terminal, and formatting the code data, the neatness of the page is improved, the readability and reusability of the codes are improved, the codes can be checked conveniently, meanwhile, the standard of mastering of the program language by a user is further reduced through conversion among multiple language types, and the user experience is improved.
FIG. 4 is a functional block diagram of a code data conversion device according to a preferred embodiment of the present invention. The code data conversion device 11 comprises a generation unit 110, a parsing unit 111, a verification unit 112, a formatting unit 113, an identification unit 114 and a recombination unit 115. The module/unit referred to in the present invention refers to a series of computer program segments that can be executed by the processor 13 and that can perform a fixed function, and that are stored in the memory 12. In the present embodiment, the functions of the modules/units will be described in detail in the following embodiments.
The generation unit 110 acquires data to be converted and generates a conversion request based on the data to be converted.
In this embodiment, the data to be converted may be code data of any language type, such as: SQL (Structured Query Language) statements, JSON (JavaScript Object Notation) statements, and the like.
Further, the data to be converted may be uploaded by a user, or may be uploaded by a back-end server, which is not limited in the present invention.
In at least one embodiment of the present invention, the conversion request may include, but is not limited to, one or more of the following combinations of information:
the language type of the data to be converted, the storage path of the data to be converted and the language identification of the data to be converted.
The parsing unit 111 parses the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted.
In at least one embodiment of the present invention, the parsing unit 111 parses the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted includes:
acquiring a file header from the conversion request;
extracting configuration items in the file header;
acquiring a first label corresponding to any language type and a second label corresponding to any storage path;
extracting data from the configuration items according to the first label, and using the data as an initial language type of the data to be converted;
and extracting data from the configuration items according to the second label, and using the data as a storage path of the data to be converted.
For example: the first tag may be a language and the second tag may be an address.
In the above embodiment, the configuration of the header can facilitate the identification of the request, and the language type and the storage path are added to the configuration item of the header, so that the required information can be directly acquired from the request, and the efficiency of data processing is improved.
The verification unit 112 obtains a verification method corresponding to the initial language type, and verifies the data stored at the storage path according to the verification method.
It can be understood that each code language has a corresponding verification method, and the verification method is mainly used for verifying the format specification of the code.
In at least one embodiment of the present invention, the verifying unit 112 obtains a verifying method corresponding to the initial language type, and verifying the data stored at the storage path according to the verifying method includes:
acquiring a pre-stored checking method list, wherein the checking method list is used for storing the corresponding relation between the checking method and the language type;
querying in the verification method list by using the initial language type, and determining a verification method corresponding to the initial language type as a target verification method;
and verifying the data stored at the storage path by using the target verification method.
For example: when the initial language type is SQL, checking whether the data stored in the storage path has formats such as SELECT and the like; when the initial language type is JSON, checking whether the data stored at the storage path has a format such as key-value.
Further, when the data stored in the storage path passes the verification, it indicates that the data to be converted is not abnormal and meets the condition of data conversion; when the data stored in the storage path is not verified, it is indicated that the data to be converted is abnormal and does not meet the condition of data conversion, and subsequent conversion does not need to be executed, so that waste of redundant running resources and waste are avoided.
Through the embodiment, the data is preliminarily checked before the conversion, and after the data passes the check, the subsequent conversion is executed, so that the unnecessary loss of resources and time caused by the execution of invalid operation is avoided.
When the data stored in the storage path passes the verification, the formatting unit 113 invokes a first target component corresponding to the initial language type from the pre-packaged formatting components, performs formatting processing on the data to be converted by using the first target component to obtain first converted data, and displays the first converted data.
In at least one embodiment of the present invention, before a first target component corresponding to the initial language type is called from a pre-packaged formatting component, a formatting component of each language type is obtained;
configuring component identification for formatting components of each language type to obtain identification of each formatting component;
acquiring a method of each formatting component, and adding the method of each formatting component into a prototype object to obtain an object corresponding to each formatting component;
and creating a constructor, and packaging the object corresponding to each formatting component according to the constructor, wherein the entry of the constructor is the identifier of each formatting component.
Through the implementation mode, formatting components of various language types can be uniformly packaged, so that global calling is facilitated.
Specifically, the formatting unit 113 performs formatting processing on the data to be converted by using the first target component, and obtaining first converted data includes:
acquiring an identifier of the first target component;
passing an identification of the first target component as an argument into the constructor;
and executing the method of the first target assembly by using the constructor, and formatting the data to be converted to obtain the first conversion data.
Through the implementation mode, the corresponding components can be called to achieve targeted formatting processing of the data, the data conversion efficiency is improved, the accuracy is higher, the packaging of various formatting components also improves the coverage of data conversion on code languages, and the practicability is higher.
In at least one embodiment of the present invention, the formatting unit 113 performs formatting processing on the data to be converted by using the first target component, and obtaining first converted data further includes:
when the initial language type is the SQL type, determining the first target component as an SQL script conversion plug-in, and performing formatting processing on the data to be converted by using the SQL script conversion plug-in to obtain the first conversion data, wherein parameters of the SQL script conversion plug-in include the language type and the character reduction amount; or
And when the initial language type is the JSON type, reading the data to be converted into a character string, determining the first target assembly as a JSON formatter extension plug-in, and formatting the character string by using the JSON formatter extension plug-in to obtain the first converted data.
The SQL script conversion plug-in can be a FormatSQL plug-in.
The JSON formatter extension plug-in can be a FormatSQL plug-in.
Through the implementation mode, the corresponding conversion assemblies are respectively called for the SQL type or the JSON type to carry out formatting processing, original disordered codes are normalized, readability of code data is improved, and identification and corresponding operation are facilitated.
In at least one embodiment of the present invention, the displaying the first conversion data comprises:
acquiring an editor corresponding to a front-end interface;
displaying the first converted data on the editor.
The editor is used for compiling codes, and relevant tasks can be executed after compiling.
Through the implementation mode, the original code data which is difficult to understand is formatted and then displayed on the editor at the front end for relevant workers to read.
When receiving an instruction to transmit the first converted data to a target terminal, the identifying unit 114 identifies a language type corresponding to the target terminal as a target language type.
In this embodiment, the instruction may be triggered by a relevant worker, such as a developer.
For example: after the first conversion data is displayed, a developer A determines that an executive party of a next task is a terminal B by reading codes, then determines the terminal B as the target terminal, and can trigger an instruction for transmitting the first conversion data to the terminal B by clicking a designated button or voice control and the like.
In this embodiment, the target terminal corresponds to a downstream device, and refers to a recipient of the translated language, and is configured to execute a specific task and the like according to the translated code.
In this embodiment, the data conversion requirement of the target terminal may be read, or the language type of the target terminal may be read, so as to determine the language type corresponding to the target terminal.
For example: the attribute data of the target terminal can be read, and the language type corresponding to the target terminal is obtained from the attribute data and is used as the target language type.
The formatting unit 113 invokes a second target component corresponding to the target language type from the formatting components, and performs formatting processing on the first conversion data by using the second target component to obtain second conversion data.
For example: and when the target language type is JSON and the language type of the first conversion data is SQL, the second target assembly is a plug-in capable of converting the SQL statement into the JSON statement.
Specifically, the manner of performing formatting processing on the first conversion data by using the second target component to obtain the second conversion data is similar to the manner of performing formatting processing on the data to be converted by using the first target component, which is not described herein again.
The restructuring unit 115 restructures the second conversion data to obtain target data, and sends the target data to the target terminal.
In the embodiment, the code data is formatted, so that the neatness of the page is improved, the readability and reusability of the code are improved, the code is convenient to check, the standard of mastering the program language by a user is further reduced through conversion among multiple language types, and the user experience is improved.
In at least one embodiment of the present invention, when the second conversion data is recombined to obtain target data and the target data is sent to the target terminal, check bytes are added to the second conversion data to obtain the target data;
and when the target data is sent to the target terminal, the target terminal is informed to verify the received data by using the check bytes.
The check byte can be configured by self-definition, such as 8-bit cyclic redundancy check code.
Through the embodiment, when the converted data is transmitted to the target terminal, the target terminal can judge whether the corresponding data is successfully received according to the check bytes through the data recombination, so that the stability of data transmission is improved, and transmission errors are effectively avoided.
Of course, in other embodiments, in order to further ensure the security of data transmission, the target data may also be encrypted for transmission, which is not described herein again.
It should be noted that, in order to further improve the security of the data and avoid malicious tampering of the data, the target data block chain node is provided.
According to the technical scheme, the invention can obtain the data to be converted, generate the conversion request based on the data to be converted, analyze the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted, obtain the verification method corresponding to the initial language type, verify the data stored in the storage path according to the verification method, perform preliminary verification on the data before conversion, perform subsequent conversion after verification is passed, avoid performing invalid operation to cause unnecessary loss of resources and time, call a first target component corresponding to the initial language type from a pre-packaged formatting component when the data stored in the storage path passes verification, and perform formatting processing on the data to be converted by using the first target component, the method comprises the steps of obtaining first conversion data, displaying the first conversion data, calling corresponding components to achieve targeted formatting of the data, improving data conversion efficiency, being higher in accuracy, improving the coverage of data conversion to code languages due to packaging of various formatting components, being higher in practicability, identifying the language type corresponding to a target terminal as a target language type when receiving an instruction for transmitting the first conversion data to the target terminal, calling a second target component corresponding to the target language type from the formatting components, formatting the first conversion data by using the second target component to obtain second conversion data, recombining the second conversion data to obtain target data, transmitting the target data to the target terminal, and formatting the code data, the neatness of the page is improved, the readability and reusability of the codes are improved, the codes can be checked conveniently, meanwhile, the standard of mastering of the program language by a user is further reduced through conversion among multiple language types, and the user experience is improved.
Fig. 5 is a schematic structural diagram of a computer device according to a preferred embodiment of the present invention for implementing the code data conversion method.
The computer device 1 may comprise a memory 12, a processor 13 and a bus, and may further comprise a computer program, such as a code data translation program, stored in the memory 12 and executable on the processor 13.
It will be understood by those skilled in the art that the schematic diagram is merely an example of the computer device 1, and does not constitute a limitation to the computer device 1, the computer device 1 may have a bus-type structure or a star-shaped structure, the computer device 1 may further include more or less other hardware or software than those shown, or different component arrangements, for example, the computer device 1 may further include an input and output device, a network access device, etc.
It should be noted that the computer device 1 is only an example, and other electronic products that are currently available or may come into existence in the future, such as electronic products that can be adapted to the present invention, should also be included in the scope of the present invention, and are included herein by reference.
The memory 12 includes at least one type of readable storage medium, which includes flash memory, removable hard disks, multimedia cards, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disks, optical disks, etc. The memory 12 may in some embodiments be an internal storage unit of the computer device 1, for example a removable hard disk of the computer device 1. The memory 12 may also be an external storage device of the computer device 1 in other embodiments, such as a plug-in removable hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), etc. provided on the computer device 1. Further, the memory 12 may also include both an internal storage unit and an external storage device of the computer device 1. The memory 12 can be used not only for storing application software installed in the computer device 1 and various types of data such as codes of a code data converting program, etc., but also for temporarily storing data that has been output or is to be output.
The processor 13 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 13 is a Control Unit (Control Unit) of the computer device 1, connects various components of the whole computer device 1 by using various interfaces and lines, and executes various functions and processes data of the computer device 1 by running or executing programs or modules (for example, executing a code data conversion program and the like) stored in the memory 12 and calling data stored in the memory 12.
The processor 13 executes the operating system of the computer device 1 and various installed application programs. The processor 13 executes the application program to implement the steps in the above-described code data conversion method embodiments, such as the steps shown in fig. 1.
Illustratively, the computer program may be divided into one or more modules/units, which are stored in the memory 12 and executed by the processor 13 to accomplish the present invention. The one or more modules/units may be a series of computer readable instruction segments capable of performing certain functions, which are used to describe the execution of the computer program in the computer device 1. For example, the computer program may be divided into a generation unit 110, a parsing unit 111, a verification unit 112, a formatting unit 113, a recognition unit 114, a reorganization unit 115.
The integrated unit implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a computer device, or a network device) or a processor (processor) to execute the code data conversion method according to the embodiments of the present invention.
The integrated modules/units of the computer device 1 may be stored in a computer-readable storage medium if they are implemented in the form of software functional units and sold or used as separate products. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented.
Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), random-access Memory, or the like.
Further, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one line is shown in FIG. 5, but it is not intended that there be only one bus or one type of bus. The bus is arranged to enable connection communication between the memory 12 and at least one processor 13 or the like.
Although not shown, the computer device 1 may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 13 through a power management device, so that functions of charge management, discharge management, power consumption management and the like are realized through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The computer device 1 may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the computer device 1 may further include a network interface, and optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used for establishing a communication connection between the computer device 1 and other computer devices.
Optionally, the computer device 1 may further comprise a user interface, which may be a Display (Display), an input unit, such as a Keyboard (Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the computer device 1 and for displaying a visualized user interface.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
Fig. 5 shows only a computer device 1 with components 12-13, and it will be understood by a person skilled in the art that the structure shown in fig. 5 does not constitute a limitation of the computer device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
With reference to fig. 1, the memory 12 of the computer device 1 stores a plurality of instructions to implement a code data transformation method, and the processor 13 can execute the plurality of instructions to implement:
acquiring data to be converted, and generating a conversion request based on the data to be converted;
analyzing the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted;
acquiring a verification method corresponding to the initial language type, and verifying the data stored in the storage path according to the verification method;
when the data stored in the storage path passes the verification, calling a first target component corresponding to the initial language type from a pre-packaged formatting component, formatting the data to be converted by using the first target component to obtain first converted data, and displaying the first converted data;
when an instruction for transmitting the first conversion data to a target terminal is received, identifying a language type corresponding to the target terminal as a target language type;
calling a second target component corresponding to the target language type from the formatting component, and formatting the first conversion data by using the second target component to obtain second conversion data;
and recombining the second conversion data to obtain target data, and sending the target data to the target terminal.
Specifically, the processor 13 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the instruction, which is not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The invention is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The invention may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the present invention may also be implemented by one unit or means through software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A code data conversion method, characterized in that the code data conversion method comprises:
acquiring data to be converted, and generating a conversion request based on the data to be converted;
analyzing the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted;
acquiring a verification method corresponding to the initial language type, and verifying the data stored in the storage path according to the verification method;
when the data stored in the storage path passes the verification, calling a first target component corresponding to the initial language type from a pre-packaged formatting component, formatting the data to be converted by using the first target component to obtain first converted data, and displaying the first converted data;
when an instruction for transmitting the first conversion data to a target terminal is received, identifying a language type corresponding to the target terminal as a target language type;
calling a second target component corresponding to the target language type from the formatting component, and formatting the first conversion data by using the second target component to obtain second conversion data;
and recombining the second conversion data to obtain target data, and sending the target data to the target terminal.
2. The code data conversion method according to claim 1, wherein the parsing the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted includes:
acquiring a file header from the conversion request;
extracting configuration items in the file header;
acquiring a first label corresponding to any language type and a second label corresponding to any storage path;
extracting data from the configuration items according to the first label, and using the data as an initial language type of the data to be converted;
and extracting data from the configuration items according to the second label, and using the data as a storage path of the data to be converted.
3. The code data translation method of claim 1, wherein prior to invoking the first target component corresponding to the initial language type from the pre-packaged formatting component, the method further comprises:
acquiring a formatting component of each language type;
configuring component identification for formatting components of each language type to obtain identification of each formatting component;
acquiring a method of each formatting component, and adding the method of each formatting component into a prototype object to obtain an object corresponding to each formatting component;
and creating a constructor, and packaging the object corresponding to each formatting component according to the constructor, wherein the entry of the constructor is the identifier of each formatting component.
4. The code data conversion method according to claim 3, wherein the formatting the data to be converted by using the first target component to obtain first converted data comprises:
acquiring an identifier of the first target component;
passing an identification of the first target component as an argument into the constructor;
and executing the method of the first target assembly by using the constructor, and formatting the data to be converted to obtain the first conversion data.
5. The code data conversion method according to claim 1, wherein the formatting the data to be converted by using the first target component to obtain first converted data further comprises:
when the initial language type is the SQL type, determining the first target component as an SQL script conversion plug-in, and performing formatting processing on the data to be converted by using the SQL script conversion plug-in to obtain the first conversion data, wherein parameters of the SQL script conversion plug-in include the language type and the character reduction amount; or
And when the initial language type is the JSON type, reading the data to be converted into a character string, determining the first target assembly as a JSON formatter extension plug-in, and formatting the character string by using the JSON formatter extension plug-in to obtain the first converted data.
6. The code data conversion method of claim 1, wherein the displaying the first conversion data comprises:
acquiring an editor corresponding to a front-end interface;
displaying the first converted data on the editor.
7. The code data conversion method according to claim 1, wherein when the second conversion data is reassembled to obtain target data and the target data is transmitted to the target terminal, the method further comprises:
adding check bytes in the second conversion data to obtain the target data;
and when the target data is sent to the target terminal, the target terminal is informed to verify the received data by using the check bytes.
8. A code data conversion apparatus, characterized in that the code data conversion apparatus comprises:
the generating unit is used for acquiring data to be converted and generating a conversion request based on the data to be converted;
the analysis unit is used for analyzing the conversion request to obtain the initial language type of the data to be converted and the storage path of the data to be converted;
the verification unit is used for acquiring a verification method corresponding to the initial language type and verifying the data stored in the storage path according to the verification method;
the formatting unit is used for calling a first target component corresponding to the initial language type from a pre-packaged formatting component when the data stored in the storage path passes the verification, formatting the data to be converted by using the first target component to obtain first converted data, and displaying the first converted data;
the identification unit is used for identifying the language type corresponding to the target terminal as the target language type when receiving an instruction of transmitting the first conversion data to the target terminal;
the formatting unit is further configured to invoke a second target component corresponding to the target language type from the formatting component, and perform formatting processing on the first conversion data by using the second target component to obtain second conversion data;
and the recombination unit is used for recombining the second conversion data to obtain target data and sending the target data to the target terminal.
9. A computer device, characterized in that the computer device comprises:
a memory storing at least one instruction; and
a processor executing instructions stored in the memory to implement the code data conversion method of any one of claims 1 to 7.
10. A computer-readable storage medium characterized by: the computer-readable storage medium has stored therein at least one instruction that is executed by a processor in a computer device to implement the code data conversion method of any one of claims 1 to 7.
CN202111535063.3A 2021-12-15 2021-12-15 Code data conversion method, device, equipment and medium Pending CN114237571A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111535063.3A CN114237571A (en) 2021-12-15 2021-12-15 Code data conversion method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111535063.3A CN114237571A (en) 2021-12-15 2021-12-15 Code data conversion method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN114237571A true CN114237571A (en) 2022-03-25

Family

ID=80756382

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111535063.3A Pending CN114237571A (en) 2021-12-15 2021-12-15 Code data conversion method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN114237571A (en)

Similar Documents

Publication Publication Date Title
CN113238929B (en) Code testing method and device based on Mock data, electronic equipment and storage medium
CN112015430A (en) JavaScript code translation method and device, computer equipment and storage medium
CN115964307B (en) Automatic test method, device, equipment and medium for transaction data
CN113806434B (en) Big data processing method, device, equipment and medium
CN112732567B (en) Mock data testing method and device based on ip, electronic equipment and storage medium
CN112506779A (en) Software interface testing method and device, electronic equipment and storage medium
CN115048111B (en) Code generation method, device, equipment and medium based on metadata
CN112653760A (en) Cross-server file transmission method and device, electronic equipment and storage medium
CN113051171A (en) Interface test method, device, equipment and storage medium
CN113468049A (en) Test method, device, equipment and medium based on configurable interface
CN115129753A (en) Data blood relationship analysis method and device, electronic equipment and storage medium
CN114385497A (en) Test environment generation method and device, electronic equipment and storage medium
CN114116400A (en) Application exception handling method, device, equipment and medium based on log printing
CN114185776A (en) Big data point burying method, device, equipment and medium for application program
CN114138243A (en) Function calling method, device, equipment and storage medium based on development platform
CN113051224A (en) File transmission method and device, electronic equipment and computer readable storage medium
CN114816371B (en) Message processing method, device, equipment and medium
CN115033489A (en) Code resource detection method and device, electronic equipment and storage medium
CN114237571A (en) Code data conversion method, device, equipment and medium
CN114942855A (en) Interface calling method and device, electronic equipment and storage medium
CN114185502A (en) Log printing method, device, equipment and medium based on production line environment
CN112667244A (en) Data verification method and device, electronic equipment and computer readable storage medium
CN113886244A (en) Sql statement testing method and device, electronic equipment and readable storage medium
CN118037453B (en) Order processing method, device, equipment and medium of transaction system
CN116414366B (en) Middleware interface generation method, device, equipment and 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