Text format conversion method and device, computer equipment and storage medium
By using regular expressions to clean POJO text and assemble JSON structures in Java back-end development, the problem of low conversion efficiency of text formats in traditional methods is solved, and more efficient data conversion and user experience is achieved.
Patent Information
- Application Number
- CN202410997421.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-24
- Publication Date
- 2024-11-22
AI Technical Summary
Traditional text format conversion methods have poor applicability and low work efficiency in Java back-end development, especially in the conversion process between POJO format data and JSON format data.
Regular expressions are used to clean the POJO format text unstructured information, and assemble the JSON structure to realize text format conversion through computer equipment and storage media, avoiding the use of IDE plug-ins and network services.
It improves the applicability, convenience, flexibility and work efficiency of text format conversion, improves user experience and conversion accuracy, and saves development resources.
Smart Images

Figure CN119005127A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a text format conversion method, device, computer equipment and storage medium. Background Art
[0002] In Java backend development, POJO (Plain Old Java Object) format data is often used to represent data structures within applications. JSON (JavaScript Object Notation) is a lightweight data exchange format that is easy for humans to read and write, and easy for machines to parse and generate. Therefore, the conversion between POJO format data and JSON format data is a common and critical task for front-end and back-end data interaction, API response, and configuration management.
[0003] However, traditional text format conversion methods are usually implemented using IDE plug-ins and network services, which have problems such as poor applicability or low work efficiency. Summary of the invention
[0004] Based on this, it is necessary to provide a text format conversion method, device, computer equipment and storage medium that can improve applicability and work efficiency in response to the above technical problems.
[0005] In a first aspect, a text format conversion method is provided, the method comprising:
[0006] In response to triggering the text format conversion program, obtaining the POJO format text to be converted;
[0007] In response to a click operation on a format conversion button of a text format conversion interface of a text format conversion program, a regular expression is used to perform unstructured information cleaning on the POJO format text to be converted to obtain a cleaned POJO format text to be converted;
[0008] Perform JSON structure assembly processing on the cleaned POJO format text to be converted to obtain JSON format text;
[0009] The text input box on the text format conversion interface displays text in JSON format.
[0010] In one of the embodiments, the method also includes: determining the text field type of the POJO format text to be converted based on the POJO format text to be converted; in response to the text field type being a regular field type, generating a first default fill value based on the text field type of the POJO format text to be converted; performing data filling processing on the JSON format text according to the first default fill value to obtain a first filled JSON format text; and updating the JSON format text based on the first filled JSON format text.
[0011] In one of the embodiments, the method also includes: in response to the text field type being an unconventional field type, recursively converting the POJO format text to be converted layer by layer to obtain the recursively converted POJO format text to be converted; determining the text field type of the recursively converted POJO format text to be converted according to the recursively converted POJO format text to be converted; generating a second default fill value according to the text field type of the recursively converted POJO format text to be converted; performing data filling processing on the recursively converted POJO format text to be converted according to the second default fill value to obtain a second filled JSON format text; and updating the JSON format text according to the second filled JSON format text.
[0012] In one of the embodiments, obtaining the POJO format text to be converted includes: displaying a text input box; in response to a pasting operation of copied text into the text input box, pasting the POJO format text to be converted into the text input box according to the copied text.
[0013] In one of the embodiments, obtaining the POJO format text to be converted also includes: in response to dragging the file to be converted to the text input box, parsing the file to be converted to obtain the POJO format text to be converted, and displaying the POJO format text to be converted in the text input box.
[0014] In one of the embodiments, a regular expression is used to perform unstructured information cleaning processing on a POJO format text to be converted to obtain the cleaned POJO format text to be converted, including: based on a first regular sub-expression, performing comment cleaning processing on the POJO format text to be converted to obtain the comment-cleaned POJO format text to be converted; based on a second regular sub-expression, performing field permission removal processing on the comment-cleaned POJO format text to be converted to obtain the field permission removal POJO format text to be converted; based on a third regular sub-expression, performing annotation cleaning processing on the field permission removal POJO format text to be converted to obtain the cleaned POJO format text to be converted; wherein the regular expression includes a first regular sub-expression, a second regular sub-expression and a third regular sub-expression; and the unstructured information cleaning processing includes comment cleaning processing, field permission removal processing and annotation cleaning processing.
[0015] In one of the embodiments, the method further includes: determining a target result output mode in response to a selection operation on a result output mode; and feeding back a JSON formatted text to a user terminal using the target result output mode.
[0016] In a second aspect, a text format conversion device is provided, the device comprising a text acquisition module, an information cleaning module, a format conversion module and a result display module.
[0017] Among them, the text acquisition module is used to respond to the trigger operation of the text format conversion program and obtain the POJO format text to be converted; the information cleaning module is used to respond to the format conversion button of the text format conversion interface of the text format conversion program, and use regular expressions to perform unstructured information cleaning processing on the POJO format text to be converted to obtain the cleaned POJO format text to be converted; the format conversion module is used to perform JSON structure assembly processing on the cleaned POJO format text to be converted to obtain JSON format text; the result display module is used to display the JSON format text in the text input box of the text format conversion interface.
[0018] In a third aspect, a computer device is provided. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the steps of any method in the above method embodiments are implemented.
[0019] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any method in the above method embodiments are implemented.
[0020] The above-mentioned text format conversion method, device, computer equipment and storage medium obtain the POJO format text to be converted by responding to the trigger operation of the text format conversion program; then, in response to the format conversion button of the text format conversion interface of the text format conversion program being clicked, the POJO format text to be converted is cleaned by regular expression to obtain the cleaned POJO format text to be converted; then, the POJO format text to be converted after the cleansing is assembled into a JSON structure to obtain the JSON format text; finally, the JSON format text is displayed in the text input box of the text format conversion interface, avoiding the IDE plug-in and the network service to realize the format conversion, thereby improving the applicability, convenience, flexibility and work efficiency of the text format conversion method, improving the user experience and the accuracy of the text format conversion, and saving development resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 An application environment diagram of a text format conversion method in an embodiment;
[0022] Figure 2 A first flow chart of a text format conversion method in one embodiment;
[0023] Figure 3 A schematic diagram of a process for obtaining a POJO format text to be converted in one embodiment;
[0024] Figure 4 A schematic diagram of a process of using a regular expression to clean unstructured information of a POJO format text to be converted to obtain the cleaned POJO format text to be converted in one embodiment;
[0025] Figure 5 A second flow chart of a text format conversion method in one embodiment;
[0026] Figure 6 A third flow chart of a text format conversion method in one embodiment;
[0027] Figure 7 is a structural block diagram of a text format conversion device in one embodiment;
[0028] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0030] In order to facilitate understanding of the present application, the present application will be described more fully below with reference to the relevant drawings. Embodiments of the present application are provided in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.
[0031] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0032] It is understood that the terms "first", "second", etc. used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish a first element from another element. For example, without departing from the scope of this application, a first resistor may be referred to as a second resistor, and similarly, a second resistor may be referred to as a first resistor. Both the first resistor and the second resistor are resistors, but they are not the same resistor.
[0033] It can be understood that the “connection” in the following embodiments should be understood as “electrical connection”, “communication connection”, etc. if the connected circuits, modules, units, etc. have electrical signals or data transmission between each other.
[0034] When used herein, the singular forms "a", "an", and "said / the" may also include plural forms, unless the context clearly indicates otherwise. It should also be understood that the terms "include / comprise" or "have" etc. specify the presence of stated features, wholes, steps, operations, components, parts or combinations thereof, but do not exclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts or combinations thereof.
[0035] The text format conversion method provided by this application can be applied to Figure 1 In the application environment shown in FIG. 1 , the user terminal 102 communicates with the server 104 through a network. (The user terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.)
[0036] In one embodiment, Figure 2 As shown, a text format conversion method is provided, which is applied to Figure 1 The server 104 in the example is used for explanation, and the following steps are included: step 201 to step 204.
[0037] Step 201 : in response to triggering the text format conversion program, obtaining the POJO format text to be converted.
[0038] The POJO format text to be converted is a POJO format text that needs to be converted. Specifically, when the server 104 identifies that a trigger operation is performed on the text format conversion program, the server 104 can obtain the POJO format text to be converted.
[0039] In one embodiment, if Figure 3 As shown, obtaining the POJO format text to be converted includes steps 301 to 302.
[0040] Step 301, display a text input box.
[0041] Step 302 , in response to a pasting operation of the copied text into the text input box, the POJO format text to be converted is pasted into the text input box based on the copied text.
[0042] It is understandable that before executing the text format conversion method, the text content in the POJO format that needs to be converted can be copied to generate the copied text. Specifically, the server 104 displays a text input box in the text format conversion interface of the text format conversion program; then, when the text input box is identified to paste the copied text, the POJO format text to be converted is pasted in the text input box according to the copied text, thereby improving the convenience and efficiency of obtaining the POJO format text to be converted.
[0043] In this embodiment, a text input box is displayed; then, in response to a paste operation of the copied text in the text input box, the POJO format text to be converted is pasted in the text input box based on the copied text, thereby improving the convenience and efficiency of obtaining the POJO format text to be converted.
[0044] In one embodiment, if Figure 3 As shown, obtaining the POJO format text to be converted also includes step 303.
[0045] Step 303, in response to dragging the file to be converted to the text input box, the file to be converted is parsed to obtain the POJO format text to be converted, and the POJO format text to be converted is displayed in the text input box.
[0046] It is understandable that the file to be converted is used to store the text content in POJO format that needs to be converted. Specifically, when the server 104 recognizes that the file to be converted is dragged to the text input box, it parses the file to be converted to obtain the POJO format text to be converted, and displays the POJO format text to be converted in the text input box, thereby improving the convenience and efficiency of obtaining the POJO format text to be converted.
[0047] In this embodiment, in response to dragging the file to be converted to the text input box, the file to be converted is parsed to obtain the POJO format text to be converted, and the POJO format text to be converted is displayed in the text input box, thereby improving the convenience and efficiency of obtaining the POJO format text to be converted.
[0048] Step 202 , in response to a click operation on a format conversion button on a text format conversion interface of a text format conversion program, a regular expression is used to perform unstructured information cleaning processing on the POJO format text to be converted to obtain a cleaned POJO format text to be converted.
[0049] Specifically, when the server 104 recognizes that a format conversion button in the text format conversion interface of the text format conversion program is clicked, it can use regular expressions to perform unstructured information cleaning processing on the POJO format text to be converted to obtain the cleaned POJO format text to be converted, thereby removing the non-formatted information in the POJO format text to be converted and improving the efficiency of data cleaning.
[0050] In one embodiment, if Figure 4 As shown, the POJO format text to be converted is cleaned for unstructured information using a regular expression to obtain the cleaned POJO format text to be converted, including steps 401 to 403.
[0051] Step 401 : Based on the first regular subexpression, the POJO format text to be converted is cleaned of comments to obtain the POJO format text to be converted after the comment cleaning.
[0052] Step 402: Based on the second regular subexpression, the POJO format text to be converted after the comment cleaning process is performed with field permission removal to obtain the POJO format text to be converted after the field permission removal process.
[0053] Step 403: Based on the third regular subexpression, the POJO format text to be converted after the field permission removal processing is performed with annotation cleaning processing to obtain the POJO format text to be converted after the cleaning processing.
[0054] The regular expression includes a first regular sub-expression, a second regular sub-expression and a third regular sub-expression; the unstructured information cleaning process includes comment cleaning process, field permission removal process and annotation cleaning process.
[0055] Specifically, based on the first regular subexpression, the server 104 performs comment cleaning processing on the POJO format text to be converted, and obtains the comment-cleaned POJO format text to be converted; then, based on the second regular subexpression, the server 104 performs field permission removal processing on the POJO format text to be converted that has been comment cleaned, and obtains the POJO format text to be converted after the field permission removal processing; then, based on the third regular subexpression, the server 104 performs annotation cleaning processing on the POJO format text to be converted that has been comment cleaned, and obtains the cleaned POJO format text to be converted, thereby removing non-formatted information in the POJO format text to be converted and improving the efficiency of data cleaning.
[0056] In this embodiment, based on the first regular subexpression, the POJO format text to be converted is subjected to comment cleaning processing to obtain the POJO format text to be converted after the comment cleaning processing; then, based on the second regular subexpression, the POJO format text to be converted after the comment cleaning processing is subjected to field permission removal processing to obtain the POJO format text to be converted after the field permission removal processing; then, based on the third regular subexpression, the POJO format text to be converted after the field permission removal processing is subjected to annotation cleaning processing to obtain the POJO format text to be converted after the cleaning processing, thereby removing the non-formatted information in the POJO format text to be converted, and improving the efficiency of data cleaning.
[0057] Step 203, performing JSON structure assembly processing on the cleaned POJO format text to be converted to obtain JSON format text.
[0058] Specifically, the server 104 performs JSON structure assembly processing on the cleaned POJO format text to be converted to obtain JSON format text, avoiding IDE plug-ins and network services to achieve format conversion, thereby improving the applicability and work efficiency of the text format conversion method.
[0059] In a specific example, the POJO format text to be converted after cleaning is assembled into a JSON structure to obtain the JSON format text, including: performing format conversion on each string of the POJO format text to be converted after cleaning to obtain a corresponding format-converted string; and concatenating each format-converted string to obtain the JSON format text. The above is only a specific example, which can be flexibly set according to user needs in actual applications and is not limited here.
[0060] In a specific example, a syntax analyzer can be used, but is not limited to, to assemble the cleaned POJO format text to be converted into a JSON format text after JSON structure assembly. The above is only a specific example, which can be flexibly set according to user needs in actual applications and is not limited here.
[0061] Step 204: Display the JSON format text in the text input box of the text format conversion interface.
[0062] Specifically, server 104 displays JSON format text in the text input box of the text format conversion interface, avoiding reliance on IDE plug-ins and network services to achieve format conversion, improving the applicability, convenience, flexibility and work efficiency of the text format conversion method, improving user experience and the accuracy of text format conversion, and saving development resources.
[0063] Based on this, the above-mentioned text format conversion method obtains the POJO format text to be converted by responding to the trigger operation of the text format conversion program; then, in response to the format conversion button of the text format conversion interface of the text format conversion program being clicked, the POJO format text to be converted is cleaned with regular expressions to obtain the cleaned POJO format text to be converted; then, the cleaned POJO format text to be converted is assembled into a JSON structure to obtain the JSON format text; finally, the JSON format text is displayed in the text input box of the text format conversion interface, avoiding the IDE plug-in and network service to realize the format conversion, thereby improving the applicability, convenience, flexibility and work efficiency of the text format conversion method, improving the user experience and the accuracy of the text format conversion, and saving development resources.
[0064] In one embodiment, if Figure 5 As shown, the method further includes steps 501 to 504.
[0065] Step 501: determine the text field type of the POJO format text to be converted according to the POJO format text to be converted.
[0066] Step 502: In response to the text field type being a regular field type, a first default fill value is generated according to the text field type of the POJO format text to be converted.
[0067] Step 503: perform data filling processing on the JSON format text according to the first default filling value to obtain the first filled JSON format text.
[0068] Step 504: update the JSON format text according to the first filled JSON format text.
[0069] Specifically, the server 104 determines the text field type of the POJO format text to be converted based on the POJO format text to be converted; then, when it is identified that the text field type is a regular field type, a first default fill value is generated according to the text field type of the POJO format text to be converted; then, data is filled in the JSON format text according to the first default fill value to obtain a first filled JSON format text; finally, the JSON format text is updated according to the first filled JSON format text, thereby realizing automatic filling of missing values and improving the accuracy and efficiency of text format conversion.
[0070] In this embodiment, the text field type of the POJO format text to be converted is determined according to the POJO format text to be converted; then, in response to the text field type being a regular field type, a first default fill value is generated according to the text field type of the POJO format text to be converted; then, data filling processing is performed on the JSON format text according to the first default fill value to obtain a first filled JSON format text; finally, the JSON format text is updated according to the first filled JSON format text, thereby realizing automatic filling of missing values and improving the accuracy and efficiency of text format conversion.
[0071] In one embodiment, if Figure 5 As shown, the method further includes steps 505 to step
[0072] Step 505 , in response to the text field type being a non-conventional field type, recursively convert the POJO format text to be converted layer by layer to obtain a recursively converted POJO format text to be converted.
[0073] Step 506: Determine the text field type of the POJO format text to be converted by the recursive conversion process according to the POJO format text to be converted by the recursive conversion process.
[0074] Step 507: Generate a second default filling value according to the text field type of the POJO format text to be converted by the recursive conversion process.
[0075] Step 508: perform data filling processing on the POJO format text to be converted after the recursive conversion processing according to the second default filling value to obtain the second filled JSON format text.
[0076] Step 509: Update the JSON format text according to the second filled JSON format text.
[0077] Specifically, when the server 104 identifies that the text field type is an unconventional field type, the server 104 performs layer-by-layer recursive conversion processing on the POJO format text to be converted to obtain the recursively converted POJO format text to be converted. Then, the text field type of the recursively converted POJO format text to be converted is determined based on the recursively converted POJO format text to be converted. Next, a second default fill value is generated based on the text field type of the recursively converted POJO format text to be converted; then, data is filled in the recursively converted POJO format text to be converted based on the second default fill value to obtain the second filled JSON format text; finally, the JSON format text is updated based on the second filled JSON format text, thereby improving the processing capability of complex data structures and improving the accuracy and efficiency of text format conversion.
[0078] In this embodiment, in response to the text field type being an unconventional field type, the POJO format text to be converted is recursively converted layer by layer to obtain the POJO format text to be converted that is recursively converted; then, the text field type of the POJO format text to be converted that is recursively converted is determined according to the POJO format text to be converted that is recursively converted; then, a second default fill value is generated according to the text field type of the POJO format text to be converted that is recursively converted; then, data is filled in the POJO format text to be converted that is recursively converted according to the second default fill value to obtain a second filled JSON format text; finally, the JSON format text is updated according to the second filled JSON format text, thereby improving the processing capability of complex data structures and improving the accuracy and efficiency of text format conversion.
[0079] In one embodiment, if Figure 6 As shown, the method further includes step 601 to step 602.
[0080] Step 601, in response to a selection operation on a result output mode, determining a target result output mode.
[0081] Step 602: Feedback the JSON format text to the user terminal using the target result output method.
[0082] Specifically, upon recognizing the selection operation on the result output method, the server 104 determines the target result output method; then, the target result output method is used to feed back the JSON format text to the user terminal, thereby improving the user experience and the convenience of the text format conversion method, so that the user can perform test operations, interactive operations or display operations on the JSON format text at the user terminal.
[0083] In this embodiment, in response to the selection operation of the result output mode, the target result output mode is determined; then, the JSON format text is fed back to the user terminal using the target result output mode, thereby improving the user experience and the convenience of the text format conversion method, so that the user can perform test operations, interactive operations or display operations on the JSON format text at the user terminal.
[0084] It should be understood that although Figure 2-6 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-6 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0085] In a second aspect, a text format conversion device is provided, such as Figure 7 As shown, the device includes a text acquisition module 710, an information cleaning module 720, a format conversion module 730 and a result display module 740.
[0086] Among them, the text acquisition module 710 is used to respond to the trigger operation of the text format conversion program and obtain the POJO format text to be converted; the information cleaning module 720 is used to respond to the format conversion button of the text format conversion interface of the text format conversion program, and use regular expressions to perform unstructured information cleaning processing on the POJO format text to be converted to obtain the cleaned POJO format text to be converted; the format conversion module 730 is used to perform JSON structure assembly processing on the cleaned POJO format text to be converted to obtain JSON format text; the result display module 740 is used to display the JSON format text in the text input box of the text format conversion interface.
[0087] In one of the embodiments, the device further includes a data filling module.
[0088] Among them, the data filling module is used to determine the text field type of the POJO format text to be converted according to the POJO format text to be converted; the data filling module is used to generate a first default filling value according to the text field type of the POJO format text to be converted in response to the text field type being a regular field type; the data filling module is used to perform data filling processing on the JSON format text according to the first default filling value to obtain the first filled JSON format text; the data filling module is used to update the JSON format text according to the first filled JSON format text.
[0089] In one of the embodiments, a data filling module is used to, in response to a text field type being an unconventional field type, recursively convert the POJO format text to be converted layer by layer to obtain the recursively converted POJO format text to be converted; the data filling module is used to determine the text field type of the POJO format text to be converted recursively converted based on the POJO format text to be converted recursively converted; the data filling module is used to generate a second default filling value based on the text field type of the POJO format text to be converted recursively converted; the data filling module is used to perform data filling processing on the POJO format text to be converted recursively converted based on the second default filling value to obtain the second filled JSON format text; the data filling module is used to update the JSON format text based on the second filled JSON format text.
[0090] In one embodiment, the text acquisition module 710 includes a text acquisition unit.
[0091] The text acquisition unit is used to display a text input box; the text acquisition unit is used to respond to a pasting operation of the copied text in the text input box, and paste the POJO format text to be converted in the text input box according to the copied text.
[0092] In one embodiment, the text acquisition unit is used to respond to dragging the file to be converted to the text input box, parse the file to be converted to obtain the POJO format text to be converted, and display the POJO format text to be converted in the text input box.
[0093] In one embodiment, the information cleaning module 720 includes an information cleaning unit.
[0094] Among them, the information cleaning unit is used to perform comment cleaning processing on the POJO format text to be converted based on the first regular subexpression, and obtain the POJO format text to be converted after the comment cleaning processing; the information cleaning unit is used to perform field permission removal processing on the POJO format text to be converted after the comment cleaning processing based on the second regular subexpression, and obtain the POJO format text to be converted after the field permission removal processing; the information cleaning unit is used to perform annotation cleaning processing on the POJO format text to be converted after the field permission removal processing based on the third regular subexpression, and obtain the POJO format text to be converted after the cleaning processing; wherein, the regular expression includes the first regular subexpression, the second regular subexpression and the third regular subexpression; the unstructured information cleaning processing includes comment cleaning processing, field permission removal processing and annotation cleaning processing.
[0095] In one of the embodiments, the device further includes a text feedback module.
[0096] Among them, the text feedback module is used to determine the target result output mode in response to the selection operation of the result output mode; the text feedback module is used to feed back the JSON format text to the user terminal using the target result output mode.
[0097] The specific definition of the text format conversion device can be found in the definition of the text format conversion method above, which will not be repeated here. Each module in the above-mentioned text format conversion device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0098] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store POJO format text to be converted. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a text format conversion method is implemented.
[0099] Those skilled in the art will understand that Figure 8The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0100] In a third aspect, a computer device is provided. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the steps of any method in the above method embodiments are implemented.
[0101] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of any method in the above method embodiments are implemented.
[0102] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct RAMbus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0103] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0104] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A text format conversion method, the method comprising: In response to triggering the text format conversion program, obtaining the POJO format text to be converted; In response to a click operation on a format conversion button of a text format conversion interface of the text format conversion program, a regular expression is used to perform unstructured information cleaning processing on the POJO format text to be converted to obtain the cleaned POJO format text to be converted; Performing JSON structure assembly processing on the POJO format text to be converted after the cleaning process to obtain a JSON format text; The JSON format text is displayed in the text input box of the text format conversion interface.
2. The method according to claim 1, characterized in that The method further comprises: Determine the text field type of the POJO format text to be converted according to the POJO format text to be converted; In response to the text field type being a regular field type, generating a first default fill value according to the text field type of the POJO format text to be converted; Perform data filling processing on the JSON format text according to the first default filling value to obtain the JSON format text after the first filling; The JSON formatted text is updated according to the JSON formatted text after the first filling.
3. The method according to claim 2, characterized in that The method further comprises: In response to the text field type being an unconventional field type, recursively converting the POJO format text to be converted layer by layer to obtain the recursively converted POJO format text to be converted; Determine the text field type of the POJO format text to be converted by the recursive conversion process according to the POJO format text to be converted by the recursive conversion process; Generate a second default fill value according to the text field type of the POJO format text to be converted in the recursive conversion process; Perform data filling processing on the POJO format text to be converted after the recursive conversion according to the second default filling value to obtain the JSON format text after the second filling; The JSON formatted text is updated according to the second filled JSON formatted text.
4. The method according to claim 1, characterized in that: The step of obtaining the POJO format text to be converted includes: Displaying the text input box; In response to a pasting operation of the copied text into the text input box, the POJO format text to be converted is pasted into the text input box according to the copied text.
5. The method according to claim 4, characterized in that The step of obtaining the POJO format text to be converted further includes: In response to dragging the file to be converted to the text input box, the file to be converted is parsed to obtain the POJO format text to be converted, and the POJO format text to be converted is displayed in the text input box.
6. The method according to claim 1, characterized in that The step of using regular expressions to clean the unstructured information of the POJO format text to be converted to obtain the cleaned POJO format text to be converted includes: Based on the first regular subexpression, the POJO format text to be converted is subjected to comment cleaning processing to obtain the POJO format text to be converted after the comment cleaning processing; Based on the second regular subexpression, the POJO format text to be converted after the comment cleaning process is subjected to field permission removal process to obtain the POJO format text to be converted after the field permission removal process; Based on the third regular sub-expression, the POJO format text to be converted after the field permission removal processing is subjected to annotation cleaning processing to obtain the POJO format text to be converted after the cleaning processing; wherein, the regular expression includes the first regular sub-expression, the second regular sub-expression and the third regular sub-expression; the unstructured information cleaning processing includes the annotation cleaning processing, the field permission removal processing and the annotation cleaning processing.
7. The method according to claim 1, characterized in that The method further comprises: In response to a selection operation on a result output mode, determining a target result output mode; The target result output mode is used to feed back the JSON format text to the user terminal.
8. A text format conversion device, characterized in that: The device comprises: A text acquisition module, used for acquiring the POJO format text to be converted in response to triggering the text format conversion program; An information cleaning module, in response to a click operation on a format conversion button of a text format conversion interface of the text format conversion program, uses a regular expression to perform unstructured information cleaning processing on the POJO format text to be converted to obtain the cleaned POJO format text to be converted; A format conversion module, used for performing JSON structure assembly processing on the POJO format text to be converted after the cleaning process to obtain a JSON format text; A result display module is used to display the JSON format text in the text input box of the text format conversion interface.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
