A data conversion method, device, computer equipment and storage medium
Through the combination of template parser and template content parser, customized data conversion solves the resource waste and maintenance problems of data conversion methods in the existing technology when adding mapping relationships, achieves flexibility and scalability, and supports complex Mapping logic.
Patent Information
- Application Number
- CN202111354137.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-12
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-11-12
AI Technical Summary
Existing data conversion methods require code modifications when adding new mapping relationships, resulting in bloated code logic, difficulty in maintenance, inability to easily implement complex mapping relationships, and inability to meet fast and flexible expansion requirements.
By obtaining the template variables set by the user and the data to be converted, the template parser is used to extract the template content and determine the template keywords. The corresponding template content parser is determined based on the template keywords, and the data to be converted is converted to realize customized data conversion.
It achieves high flexibility, high versatility and high scalability of data conversion, avoids waste of resources when adding new mapping relationships, improves the convenience of extended functions, and supports more complex mapping logic.
Smart Images

Figure CN114064773B
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of data processing technology, and in particular to a data conversion method, device, computer equipment and storage medium. Background Art
[0002] At present, data conversion is generally processed through mapping relationships. For example, when an enterprise converts reconciliation file data with an external partner, a row of data in the partner's file is usually defined as a model object within the enterprise. Among them, the row data is cut according to the agreed delimiter, and the value of each column needs to be mapped to the corresponding attribute of the model. The specific processing of the mapping relationship can be implemented through configuration. By reading the configuration at the code level, the corresponding processing branch (if-else) can be selected according to the set mapping relationship. Currently supported mapping relationships include fixed values, pass-through, dictionary mapping, variables, regular expressions, etc.
[0003] However, due to the rapid development of corporate business, there are more and more partners and more and more diversified mapping relationships. The current data conversion method requires code modification every time a new mapping relationship is added (such as adding an if-else). When adding a new relationship, the front-end and back-end need to be modified and released at the same time. However, the modification of the back-end code cannot follow the open-closed principle, which leads to the need for regression testing, increases a lot of human resources consumption, and cannot easily implement complex mapping relationships. At the same time, the code logic is bloated, difficult to maintain and difficult to expand. Summary of the invention
[0004] The embodiments of the present invention provide a data conversion method, apparatus, computer equipment and storage medium to achieve fast and flexible expansion of the required mapping relationship, thereby converting data on demand.
[0005] In a first aspect, an embodiment of the present invention provides a data conversion method, the method comprising:
[0006] Get the template variables set by the user and the data to be converted;
[0007] Extracting the template content of the template variable through a template parser, and determining the template keyword according to the template content;
[0008] A corresponding template content parser is determined according to the template keyword, and the data to be converted is converted according to the template content by the template content parser to obtain target data.
[0009] Optionally, the template variable is a double-layer nested template;
[0010] Correspondingly, extracting the template content of the template variable by a template parser and determining the template keyword according to the template content includes:
[0011] Respectively extract the outer template content and the inner template content of the template variable;
[0012] Determine an outer template keyword and an inner template keyword according to the outer template content and the inner template content respectively;
[0013] The determining a corresponding template content parser according to the template keyword, and converting the to-be-converted data according to the template content by the template content parser to obtain target data, includes:
[0014] Determining a corresponding first template content parser according to the inner layer template keyword, and converting the data to be converted by the first template content parser to obtain intermediate data;
[0015] A corresponding second template content parser is determined according to the outer template keyword, and the intermediate data is converted by the second template content parser to obtain the target data.
[0016] Optionally, the template format of the template variable is: <tpl>Outer template keyword @Outer content configuration Inner template keyword @inner content configuration < / tpl> ;in, <tpl>< / tpl> Represents the outer template tag. Represents an inner template tag.
[0017] Optionally, before obtaining the template variables set by the user and the data to be converted, the method further includes:
[0018] The template variable mapper is determined from the mapping processor factory based on the user's configuration information.
[0019] Optionally, the method further includes:
[0020] The corresponding preset mapper is obtained from the mapping processor factory according to the user's configuration information, and the mapping type of the preset mapper includes at least one of fixed value, transparent transmission, dictionary mapping, variable, regular matching and conditional value.
[0021] Optionally, the design patterns used by the preset mapper include static factory pattern and strategy pattern, and the design patterns used by the template variable mapper include static factory pattern, strategy pattern and combination pattern.
[0022] Optionally, obtaining the data to be converted includes:
[0023] The data to be converted is obtained according to the preset field position and the preset field name.
[0024] In a second aspect, an embodiment of the present invention further provides a data conversion device, the device comprising:
[0025] The data acquisition module is used to obtain the template variables set by the user and the data to be converted;
[0026] A keyword determination module, used for extracting the template content of the template variable through a template parser, and determining the template keyword according to the template content;
[0027] The data conversion module is used to determine the corresponding template content parser according to the template keyword, and convert the data to be converted according to the template content through the template content parser to obtain target data.
[0028] In a third aspect, an embodiment of the present invention further provides a computer device, the computer device comprising:
[0029] one or more processors;
[0030] A memory for storing one or more programs;
[0031] When the one or more programs are executed by the one or more processors, the one or more processors implement the data conversion method provided by any embodiment of the present invention.
[0032] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the data conversion method provided by any embodiment of the present invention.
[0033] The embodiment of the present invention provides a data conversion method, which first obtains the template variables set by the user and the data to be converted, then extracts the template content of the template variable through the template parser, and determines the template keyword according to the extracted template content, and then determines the corresponding template content parser according to the obtained template keyword, and converts the data to be converted according to the template content through the template content parser to obtain the converted target data. The data conversion method provided by the embodiment of the present invention achieves high flexibility, high versatility and high scalability in the conversion between multiple data by using a customizable universal mapping relationship, i.e., template variables, and automatically identifying the template keywords therein to perform custom conversion on the data, thereby avoiding the huge waste of resources caused by the modification when a new mapping relationship is needed, and improving the convenience of the extended function, so that more complex mapping logics can be realized. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A flowchart of a data conversion method provided in Embodiment 1 of the present invention;
[0035] Figure 2 A schematic diagram of the structure of a data conversion device provided in Embodiment 2 of the present invention;
[0036] Figure 3 This is a schematic diagram of the structure of a computer device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0037] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0038] It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the steps as sequential processes, many of the steps therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0039] Embodiment 1
[0040] Figure 1 This is a flow chart of the data conversion method provided in the first embodiment of the present invention. This embodiment can be applied to situations where data conversion is required, such as the data conversion of reconciliation files between an enterprise and an external partner. The method can be executed by the data conversion device provided in the embodiment of the present invention. The device can be implemented by hardware and / or software and can generally be integrated into a computer device. Figure 1 As shown, the specific steps include:
[0041] S11. Obtain template variables set by the user and data to be converted.
[0042] Specifically, the information set by the user can be obtained by providing a human-computer interaction interface for the user, and the interface may include an input box for inputting template variables and an input box for inputting data to be converted, etc., and the user can enter the template variables corresponding to the required new mapping relationship and the data to be converted, etc. in the corresponding input box. Optionally, the acquisition of the data to be converted includes: acquiring the data to be converted according to the preset field position and the preset field name. Specifically, an input box corresponding to the preset field position and the preset field name can be added in the human-computer interaction interface, and the data to be converted can be automatically acquired according to the preset field position and the preset field name set by the user. Exemplarily, the preset field name set by the user can be the payment date (paymentDate) of the enterprise, and the preset field position can be 1, and the data with the field name paymentDate can be automatically indexed from the enterprise's data, and the data to be converted can be acquired from the subscript 1 position. Correspondingly, an input box for information such as the corresponding partner field name and the partner field data type can also be added. Exemplarily, the user can set the partner field name to the loan serial number and the partner field data type to the string type through these input boxes, so as to facilitate the provision of the converted data to the partner for storage. Furthermore, a submit button for generating new mapping rules can be added to the human-computer interaction interface, wherein the mapping rules include the mapping relationship obtained based on the set template variables and the data information to be converted (such as the enterprise's preset field name, preset field position, partner field name and partner field data type), etc. The user can use the submit button to generate a new mapping rule that can be directly selected for use. At the same time, the user can generate multiple mapping rules in this way, and the human-computer interaction interface provides an optional drop-down menu. The user can then directly select the required mapping rule in the drop-down menu when using it later, and then the currently used template variables and the data to be converted can be obtained according to the user's selection, thereby saving the time and energy spent on each reconfiguration and reducing the learning cost.
[0043] S12. Extracting the template content of the template variable through a template parser, and determining a template keyword according to the template content.
[0044] Specifically, when using the mapping relationship provided by the template variable, the template content of the template variable can be extracted using the template analyzer (TemplateAnalysisHandler), which can be specifically to remove the template tag of the template variable, and further to obtain the specific content of each component based on the removal of the template tag, wherein the template analyzer is a processing module for extracting the template content. Exemplarily, the template format of the template variable can be: <tpl> Template keyword@content configuration@data to be converted< / tpl> ,in, <tpl>< / tpl>It can represent the template tag, and the template keyword (key), content configuration and data to be converted can represent each component. The content configuration is the relevant configuration corresponding to the template keyword. For example, when the template keyword is AES (encryption), the content configuration can be the key used in the encryption process, etc. The template keyword and content configuration can be set according to actual needs. After extracting the template content of the template variable, the template keyword as one of the components can be determined by the template parser according to the template content. The template keyword can be used to represent the operation that needs to be performed on the data to be converted. In particular, the template keyword can also include information about the data to be converted, so that the template format may not include the data to be converted, that is, the template format can also be: <tpl> Template keyword @ content configuration< / tpl> wait.
[0045] S13. Determine a corresponding template content parser according to the template keyword, and convert the data to be converted according to the template content by the template content parser to obtain target data.
[0046] Specifically, after determining the template keyword, the template content parser (TemplateParserHandler) corresponding to the template keyword can be obtained in the template content parser factory (TemplateParserHandlerFactory), wherein the template content parser is a processing module for converting the data to be converted according to the mapping relationship provided by the template variable. Some available template keywords and template content parsers corresponding to each template keyword can be pre-set so that the user can directly use the existing template keywords to set new template variables. Each template content parser can together constitute a template content parser factory. When the template variable set by the user includes a template keyword that does not currently exist, the user can be prompted to develop the corresponding template content parser. After obtaining the corresponding template content parser, the template content parser can be used to convert the data to be converted to obtain the required target data.
[0047] On the basis of the above technical solution, optionally, the template variable is a double-layer nested template; accordingly, the template content of the template variable is extracted by a template parser, and a template keyword is determined according to the template content, including: respectively extracting the outer template content and the inner template content of the template variable; respectively determining the outer template keyword and the inner template keyword according to the outer template content and the inner template content; determining the corresponding template content parser according to the template keyword, and converting the data to be converted according to the template content by the template content parser to obtain target data, including: determining the corresponding first template content parser according to the inner template keyword, and converting the data to be converted by the first template content parser to obtain intermediate data; determining the corresponding second template content parser according to the outer template keyword, and converting the intermediate data by the second template content parser to obtain the target data.
[0048] Specifically, the template variable can be double-nested, that is, two identical or different template keywords can be used to perform two conversions on the data to be converted. Optionally, the template format of the template variable is: <tpl>Outer template keyword @Outer content configuration Inner template keyword @inner content configuration < / tpl> ;in, <tpl>< / tpl> Represents the outer template tag. Represents the inner template tag. The corresponding template content may include the outer template content and the inner template content. The outer template content may be all the content after removing the outer template tag, and the inner template content may be the content intercepted by the inner template tag, wherein the data obtained after processing the inner template content can be used as the processing object in the outer template content. After extracting the outer template content and the inner template content, the outer template keywords and the inner template keywords can be determined according to the outer template content and the inner template content, respectively, so as to determine the corresponding second template content parser and the first template content parser, respectively, and then the first template content parser can be used to convert the data to be converted to obtain intermediate data, and then the intermediate data can be used as the processing object of the outer template content, and the second template content parser can be used to convert the intermediate data to obtain the final target data.
[0049] For example, assuming that the paymentDate of the enterprise is 20210707, it needs to be converted into the format of 00:00:00 on July 8, 2021 after adding 1 day, and then encrypted by AES before being sent to the partner. The template variable can be set as: <tpl><h2 style=";text-align:left;direction:ltr">AES#JdP70F25g2QmrJQCWxo3IQ==@<h2 style=";text-align:left;direction:ltr"> paymentDate+1@yyyy year mm month dd day hh hour mm minute ss second < / tpl>. First, the inner template content "paymentDate+1@yyyy year mm month dd day hh hour mm minute ss second" can be extracted by the template parser, and the inner template keyword "paymentDate" can be determined. Then, according to the inner template keyword, the first template content parser is used to convert the data to be converted "20210707", and the intermediate data "2021 year 07 month 08 day 00 hour 00 minute 00 second" is obtained. Then, the outer template content "AES#JdP70F25g2QmrJQCWxo3IQ==@ paymentDate+1@yyyy year mm month dd day hh hour mm minute ss second " can be extracted by the template parser, and the outer template keyword "AES" can be determined. Further, the intermediate data can be used to replace the inner template content therein to obtain the replaced outer template content "AES#JdP70F25g2QmrJQCWxo3IQ==@2021 year 07 month 08 day 00 hour 00 minute 00 second". Then, according to the outer template keyword, the second template content parser is used to convert the intermediate data, that is, the intermediate data is encrypted by AES using the key "JdP70F25g2QmrJQCWxo3IQ==", and the final target data can be obtained. For example, "uuuuww432276y66g626ge62", then the data to be converted "20210707" will finally be converted to "uuuuww432276y66g626ge62".
[0050] Based on the above technical solution, optionally, before obtaining the template variables and the data to be converted set by the user, it further includes: determining to use a template variable mapper from the mapping processor factory according to the user's configuration information. Specifically, before using the mapping relationship provided by the template variable, it can be determined according to the user's configuration information that the current user selects to use the mapping method of the template variable to convert the data. Then, the template variable mapper (TemplateMappingHandler) can be selected in the mapping processor factory (TemplateMappingHandlerFactory). Furthermore, the template variable mapper can finally implement the function of template mapping by relying on the template parser and the template content parser. The functions of the three are independent so that they can be extended respectively. Among them, the template variable mapper is a processing module that converts the data to be converted using the mapping method of the template variable. Mappers using different mapping methods can be developed in advance to jointly form the mapping processor factory for the user to select. Only when the user selects to use the mapping method of the template variable, the input box of the template variable can be popped up so that the user can input the template variable when needed.
[0051] Further optionally, the method further includes: obtaining a corresponding preset mapper from the mapping processor factory according to the user's configuration information, and the mapping type of the preset mapper includes at least one of fixed value, pass-through, dictionary mapping, variable, regular matching and conditional value. Specifically, the data conversion method provided in this embodiment can also support traditional mapping types at the same time, and can develop corresponding preset mappers for each mapping type and add them to the mapping processor factory so that users can choose to use them. Specifically, the user can choose through a drop-down menu, so that it does not affect the implementation of the existing data conversion method, and can implement more relatively complex mapping logic through the newly added template variables. Among them, optionally, the design pattern used by the preset mapper includes static factory pattern and strategy pattern, and the design pattern used by the template variable mapper includes static factory pattern, strategy pattern and combination pattern. Specifically, the processing of the preset mapper uses static factory pattern + strategy pattern to achieve code simplification and meet the opening and closing principle, and the processing of the template variable mapper uses static factory pattern + strategy pattern + combination pattern to achieve the template nesting function of the combination of template variables on the basis of realizing the newly added mapping relationship to meet the opening and closing principle.
[0052] The technical solution provided by the embodiment of the present invention first obtains the template variables set by the user and the data to be converted, then extracts the template content of the template variable through the template parser, and determines the template keyword according to the extracted template content, and then determines the corresponding template content parser according to the obtained template keyword, and converts the data to be converted according to the template content through the template content parser to obtain the converted target data. By using a customizable universal mapping relationship, i.e., template variables, and automatically identifying the template keywords therein to perform custom conversions on the data, high flexibility, high versatility and high scalability of conversions between multiple data are achieved, avoiding the huge waste of resources caused by modifications when a new mapping relationship is needed, and improving the convenience of extended functions, so that more complex mapping logics can be realized.
[0053] Embodiment 2
[0054] Figure 2 This is a schematic diagram of the structure of a data conversion device provided in the second embodiment of the present invention. The device can be implemented by hardware and / or software, and can generally be integrated into a computer device to execute the data conversion method provided in any embodiment of the present invention. Figure 2 As shown, the device comprises:
[0055] The data acquisition module 21 is used to acquire the template variables set by the user and the data to be converted;
[0056] A keyword determination module 22, configured to extract the template content of the template variable through a template parser, and determine the template keyword according to the template content;
[0057] The data conversion module 23 is used to determine the corresponding template content parser according to the template keyword, and convert the data to be converted according to the template content through the template content parser to obtain target data.
[0058] The technical solution provided by the embodiment of the present invention first obtains the template variables set by the user and the data to be converted, then extracts the template content of the template variable through the template parser, and determines the template keyword according to the extracted template content, and then determines the corresponding template content parser according to the obtained template keyword, and converts the data to be converted according to the template content through the template content parser to obtain the converted target data. By using a customizable universal mapping relationship, i.e., template variables, and automatically identifying the template keywords therein to perform custom conversions on the data, high flexibility, high versatility and high scalability of conversions between multiple data are achieved, avoiding the huge waste of resources caused by modifications when a new mapping relationship is needed, and improving the convenience of extended functions, so that more complex mapping logics can be realized.
[0059] On the basis of the above technical solution, optionally, the template variable is a double-layer nested template;
[0060] Accordingly, the keyword determination module 22 includes:
[0061] A template content extraction unit, used to extract the outer layer template content and the inner layer template content of the template variable respectively;
[0062] A keyword determination unit, used to determine an outer template keyword and an inner template keyword according to the outer template content and the inner template content respectively;
[0063] The data conversion module 23 includes:
[0064] An intermediate data acquisition unit, used to determine a corresponding first template content parser according to the inner layer template keyword, and convert the data to be converted by the first template content parser to obtain intermediate data;
[0065] The target data acquisition unit is used to determine the corresponding second template content parser according to the outer template keyword, and convert the intermediate data through the second template content parser to obtain the target data.
[0066] Based on the above technical solution, optionally, the template format of the template variable is: <tpl>Outer template keyword @Outer content configuration Inner template keyword @inner content configuration < / tpl> ;in,<tpl>< / tpl> Represents the outer template tag. Represents an inner template tag.
[0067] On the basis of the above technical solution, optionally, the data conversion device further includes:
[0068] The template variable mapper selection module is used to determine the template variable mapper to be used from the mapping processor factory according to the user's configuration information before obtaining the template variables set by the user and the data to be converted.
[0069] On the basis of the above technical solution, optionally, the data conversion device further includes:
[0070] The preset mapper selection module is used to obtain the corresponding preset mapper from the mapping processor factory according to the user's configuration information, and the mapping type of the preset mapper includes at least one of fixed value, transparent transmission, dictionary mapping, variable, regular matching and conditional value.
[0071] On the basis of the above technical solution, optionally, the design patterns used by the preset mapper include static factory pattern and strategy pattern, and the design patterns used by the template variable mapper include static factory pattern, strategy pattern and combination pattern.
[0072] On the basis of the above technical solution, optionally, the data acquisition module 21 is specifically used for:
[0073] The data to be converted is obtained according to the preset field position and the preset field name.
[0074] The data conversion device provided in the embodiment of the present invention can execute the data conversion method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0075] It is worth noting that in the above-mentioned embodiment of the data conversion device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0076] Embodiment 3
[0077] Figure 3 The schematic diagram of the structure of the computer device provided for the third embodiment of the present invention shows a block diagram of an exemplary computer device suitable for implementing the implementation mode of the present invention. Figure 3 The computer device shown is only an example and should not limit the functions and scope of use of the embodiments of the present invention. Figure 3As shown, the computer device includes a processor 31, a memory 32, an input device 33 and an output device 34; the number of processors 31 in the computer device can be one or more. Figure 3 Taking a processor 31 as an example, the processor 31, memory 32, input device 33 and output device 34 in the computer device can be connected through a bus or other means. Figure 3 The example of connecting through bus is taken in the following.
[0078] The memory 32 is a computer-readable storage medium that can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the data conversion method in the embodiment of the present invention (for example, the data acquisition module 21, the keyword determination module 22 and the data conversion module 23 in the data conversion device). The processor 31 executes various functional applications and data processing of the computer device by running the software programs, instructions and modules stored in the memory 32, that is, realizes the above-mentioned data conversion method.
[0079] The memory 32 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 32 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 32 may further include a memory remotely arranged relative to the processor 31, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0080] The input device 33 can be used to obtain template variables set by the user and data to be converted, and generate key signal input related to user settings and function control of the computer device, etc. The output device 34 can include devices such as display screens, which can be used to provide users with a friendly human-computer interaction interface, etc.
[0081] Embodiment 4
[0082] Embodiment 4 of the present invention further provides a storage medium containing computer executable instructions, wherein the computer executable instructions are used to execute a data conversion method when executed by a computer processor, the method comprising:
[0083] Get the template variables set by the user and the data to be converted;
[0084] Extracting the template content of the template variable through a template parser, and determining the template keyword according to the template content;
[0085] A corresponding template content parser is determined according to the template keyword, and the data to be converted is converted according to the template content by the template content parser to obtain target data.
[0086] The storage medium may be any of various types of memory devices or storage devices. The term "storage medium" is intended to include: installation media, such as CD-ROM, floppy disk or tape device; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in the computer system in which the program is executed, or may be located in a different second computer system, which is connected to the computer system via a network (such as the Internet). The second computer system may provide program instructions to the computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations (e.g., in different computer systems connected via a network). The storage medium may store program instructions (e.g., embodied as a computer program) that may be executed by one or more processors.
[0087] Of course, the computer executable instructions of a storage medium including computer executable instructions provided by an embodiment of the present invention are not limited to the operations of the method described above, but can also execute related operations in the data conversion method provided by any embodiment of the present invention.
[0088] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0089] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0090] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0091] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A data conversion method, characterized in that: include: Get the template variables set by the user and the data to be converted; Extracting the template content of the template variable through a template parser, and determining the template keyword according to the template content; Determine a corresponding template content parser according to the template keyword, and convert the data to be converted according to the template content by the template content parser to obtain target data; wherein the template content parser is a processing module for converting the data to be converted according to the mapping relationship provided by the template variable; The step of obtaining the data to be converted comprises: The data to be converted is obtained according to the preset field position and the preset field name.
2. The data conversion method according to claim 1, characterized in that: The template variable is a double-layer nested template; Correspondingly, extracting the template content of the template variable by a template parser and determining the template keyword according to the template content includes: Respectively extract the outer template content and the inner template content of the template variable; Determine an outer template keyword and an inner template keyword according to the outer template content and the inner template content respectively; The determining a corresponding template content parser according to the template keyword, and converting the to-be-converted data according to the template content by the template content parser to obtain target data, includes: Determining a corresponding first template content parser according to the inner layer template keyword, and converting the data to be converted by the first template content parser to obtain intermediate data; A corresponding second template content parser is determined according to the outer template keyword, and the intermediate data is converted by the second template content parser to obtain the target data.
3. The data conversion method according to claim 2, characterized in that: The template format of the template variable is: <tpl>Outer template keyword @Outer content configuration Inner template keyword @inner content configuration < / tpl> ;in, <tpl>< / tpl> Represents the outer template tag. Represents an inner template tag.
4. The data conversion method according to claim 1, characterized in that: Before obtaining the template variables set by the user and the data to be converted, the method further includes: The template variable mapper is determined from the mapping processor factory based on the user's configuration information.
5. The data conversion method according to claim 4, characterized in that: The method further comprises: The corresponding preset mapper is obtained from the mapping processor factory according to the user's configuration information, and the mapping type of the preset mapper includes at least one of fixed value, transparent transmission, dictionary mapping, variable, regular matching and conditional value.
6. The data conversion method according to claim 5, characterized in that: The design patterns used by the preset mapper include static factory pattern and strategy pattern, and the design patterns used by the template variable mapper include static factory pattern, strategy pattern and combination pattern.
7. A data conversion device, characterized in that: include: The data acquisition module is used to obtain the template variables set by the user and the data to be converted; A keyword determination module, used for extracting the template content of the template variable through a template parser, and determining the template keyword according to the template content; A data conversion module, used to determine a corresponding template content parser according to the template keyword, and convert the data to be converted according to the template content through the template content parser to obtain target data; wherein the template content parser is a processing module used to convert the data to be converted according to the mapping relationship provided by the template variable; The data acquisition module is specifically used to acquire the data to be converted according to the preset field position and the preset field name.
8. A computer device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the data conversion method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the data conversion method as described in any one of claims 1 to 6 is implemented.
