Model class file automatic generation method, device, storage medium and electronic device
By automatically generating model class files, the problem of low efficiency and high error rate of manually writing model classes in the existing technology is solved, and efficient and low-error rate model class file generation is achieved.
Patent Information
- Application Number
- CN202111466259.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-03
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2041-12-03
AI Technical Summary
In the prior art, when writing a model class, it is necessary to manually create and write code, resulting in low work efficiency and high error rate.
By obtaining the interface document address, parsing the web page to obtain a unique identifier, analyzing the web page data and generating json data and comment description information, the model class file is automatically generated.
The model class files are automatically generated, which improves work efficiency, reduces error rate, and only needs to replace the new files when updating, reducing the writing workload.
Smart Images

Figure CN114138244B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of mobile Internet technology, and in particular to a method, device, storage medium and electronic device for automatically generating model class files. Background Art
[0002] Currently, during the code development process, in order to facilitate development and improve code readability and maintainability, it is necessary to create corresponding model classes. The code will be written by operating model class objects rather than directly operating complex data.
[0003] When writing model classes for various platforms, the following methods are commonly used: 1. Manually write code based on the interface documentation agreed upon between the frontend and backend, adding code comments and descriptions; 2. Copy sample data and use a JSON-to-model tool or web widget to convert it into a model class for each platform, manually adding comments and descriptions; 3. Use a development tool IDE plug-in to convert JSON data into the corresponding model, manually adding comments and descriptions.
[0004] Therefore, if the above method is used to write a model class, the model class needs to be created manually; the code needs to be written manually, and the annotation description information needs to be written manually. In other words, when writing a model class using the existing method, most of the work needs to be done manually, which is inefficient. Summary of the Invention
[0005] In view of this, embodiments of the present invention provide a method, device, storage medium and electronic device for automatically generating a model class file to solve the technical problem of low work efficiency when writing model classes in the prior art.
[0006] The technical solutions proposed by the present invention are as follows:
[0007] A first aspect of an embodiment of the present invention provides a method for automatically generating a model class file, comprising: obtaining an interface document address; parsing a web page according to the interface document address to obtain a unique identifier; obtaining web page data according to the unique identifier; and generating a model class file based on json data and annotation description information obtained by parsing the web page data.
[0008] Optionally, web page parsing is performed according to the interface document address to obtain a unique identifier, including: determining the website type according to the interface document address; when the website type is a static type, obtaining the unique identifier according to the interface document address; when the website type is a dynamic type, obtaining the unique identifier in an automated manner.
[0009] Optionally, obtaining the unique identifier in an automated manner includes: automatically running the interface document address according to a driving framework to obtain web page code data; and parsing the web page code data according to a preset protocol to obtain the unique identifier.
[0010] Optionally, obtaining web page data according to the unique identifier analysis includes: running a tag corresponding to the unique identifier according to a driving framework to obtain markdown format web page data.
[0011] Optionally, a model class file is generated based on the json data and annotation description information obtained by parsing the web page data, including: parsing the web page data to obtain json data; parsing the json data according to a recursive algorithm to obtain various attribute data of the model class and the annotation description information corresponding to each attribute; and generating a model class file based on the annotation description information corresponding to each attribute and a preset model template.
[0012] Optionally, the json data is parsed according to a recursive algorithm to obtain the attribute data of the model class and the annotation description information corresponding to each attribute, including: according to the type of the json data, using a recursive algorithm to parse to obtain the attribute data of the model class; parsing the web page data to obtain the annotation description information; obtaining the annotation description information corresponding to each attribute based on the attribute data and annotation description information of the model class.
[0013] Optionally, according to the type of json data, a recursive algorithm is used for parsing to obtain the various attribute data of the model class, including: when the format of the json data is a string type, generating the various attribute data of the model class according to the json data; when the format of the json data is a dictionary type, a recursive algorithm is used for parsing to parse out the string type in the dictionary and generate the various attribute data of the model class; when the format of the json data is an array type, a recursive algorithm is used for parsing to reduce the array type to a dictionary type, and the dictionary type parsing method is used to generate the various attribute data of the model class.
[0014] The second aspect of an embodiment of the present invention provides a device for automatically generating a model class file, including: an address acquisition module for acquiring an interface document address; a parsing module for parsing a web page according to the interface document address to obtain a unique identifier; an identifier analysis module for obtaining web page data according to the unique identifier analysis; and a model class file generation module for generating a model class file based on json data and annotation description information obtained by parsing the web page data.
[0015] A third aspect of an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the method for automatically generating model class files as described in the first aspect of the embodiment of the present invention and any one of the first aspects.
[0016] A fourth aspect of an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to execute the method for automatically generating model class files as described in the first aspect of the embodiment of the present invention and any one of the first aspects.
[0017] The technical solution provided by the present invention has the following effects:
[0018] The model class file automatic generation method, device, storage medium, and electronic device provided in the embodiments of the present invention obtain an interface document address; parse a web page according to the interface document address to obtain a unique identifier; analyze and obtain web page data according to the unique identifier; and generate a model class file based on the JSON data and annotation description information obtained by parsing the web page data. Thus, the model class file automatic generation method can automatically generate the corresponding model class file by entering the interface document address, which is convenient and fast, greatly improving work efficiency. At the same time, since the annotation description information in the model class file is automatically generated, the error rate is low. Moreover, when performing updates and iterations, only a new model class file needs to be automatically generated to replace the old file, reducing the workload of writing. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0020] Figure 1 is a flowchart of a method for automatically generating a model class file according to an embodiment of the present invention;
[0021] Figure 2 is a flowchart of a method for automatically generating a model class file according to another embodiment of the present invention;
[0022] Figure 3 is a flowchart of a method for automatically generating a model class file according to another embodiment of the present invention;
[0023] Figure 4 is a flowchart of a method for automatically generating a model class file according to another embodiment of the present invention;
[0024] Figure 5 is a structural block diagram of an apparatus for automatically generating model class files according to an embodiment of the present invention;
[0025] Figure 6 is a schematic diagram of the structure of a computer-readable storage medium provided according to an embodiment of the present invention;
[0026] Figure 7 is a schematic structural diagram of an electronic device provided according to an embodiment of the present invention. DETAILED DESCRIPTION
[0027] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present invention.
[0028] As shown in the background technology, when the model class is written in the existing way, it needs to be written manually. One of the writing methods is to open the interface document address, copy the json data, generate the model code with a third-party tool, copy the code generated by the third-party tool, paste it into the project, and then add corresponding annotation information to each data of the model. Using this writing method, it is necessary to compare the interface document and write the code field by field. It can be seen from this that the existing writing method is relatively cumbersome and has low work efficiency. Moreover, in terms of annotation information maintenance, it is necessary to compare with the interface document fields one by one, and then copy the annotation description information, which has a high error rate. In addition, when an update occurs, it is necessary to compare each data in the interface document one by one to see if there is any change, which increases the workload of writing.
[0029] In view of this, an embodiment of the present invention provides a method for automatically generating a model class file to solve the technical problems in the prior art of low efficiency and high error rate in manually writing model classes.
[0030] According to an embodiment of the present invention, a method for automatically generating a model class file is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0031] In this embodiment, a method for automatically generating a model class file is provided, which can be used in electronic devices such as computers, mobile phones, tablet computers, etc. Figure 1: is a flow chart of a method for automatically generating a model class file according to an embodiment of the present invention. Figure 1 As shown, the method includes the following steps:
[0032] Step S101: Obtain an interface document address. Specifically, the interface document address can be input by the user. For example, when a document needs to be converted into a model class file, the interface document address URL can be input into the electronic device, and the electronic device automatically parses the interface document address to generate the model class file.
[0033] Step S102: Parse the web page according to the interface document address to obtain a unique identifier. After obtaining the interface document address, the electronic device can determine the web page corresponding to the interface document address, and then parse the web page corresponding to the interface document address to obtain a unique identifier of the web page tag, or the real ID of the tag.
[0034] Step S103: Analyze and obtain web page data based on the unique identifier. Specifically, the unique identifier can be parsed and processed using an automated framework to obtain web page data in markdown format.
[0035] Step S104: Generate a model class file based on the JSON data and annotation description information obtained from parsing the webpage data. Specifically, when generating the model class file, the platform corresponding to the model can be determined and the model template for that platform can be obtained. Then, the JSON data and annotation description information can be obtained from parsing the webpage data to obtain annotated model code. This annotated model code is written into the model template to generate the corresponding model class file, thereby achieving automatic creation of the model class file. The generated model class file can also be copied to the project for application.
[0036] The method for automatically generating a model class file provided by an embodiment of the present invention obtains an interface document address; parses a web page based on the interface document address to obtain a unique identifier; analyzes the web page data based on the unique identifier; and generates a model class file based on the JSON data and annotation description information obtained by parsing the web page data. Thus, the method automatically generates a corresponding model class file by simply entering the interface document address, which is convenient and quick, greatly improving work efficiency. Furthermore, since the annotation description information in the model class file is automatically generated, the error rate is low. Furthermore, when performing updates and iterations, only a new model class file needs to be automatically generated to replace the old one, reducing the workload of writing.
[0037] In one embodiment, if Figure 2 As shown, performing web page parsing according to the interface document address to obtain a unique identifier includes the following steps:
[0038] Step S201: Determine the website type based on the interface document address. After receiving the interface document address, the electronic device can analyze the URL to determine whether the corresponding website type is dynamic or static, thereby determining how to obtain the unique identifier. The determination of whether it is a static website or a dynamic network can be made based on the URL. For example, the URL of a static website may have a suffix such as .html, htm, .shtml, or .xml, while the URL of a dynamic website typically contains a question mark. Therefore, the type of website can be determined based on the URL.
[0039] Step S202: When the website type is static, the unique identifier is obtained based on the interface document address. Specifically, when the website type is determined to be static, the website metadata can be directly obtained through a network request based on the interface document address. The unique identifier can be determined by directly analyzing the data. The unique identifier is also the unique identifier of the HTML tag, or the real ID of the tag.
[0040] Step S203: When the website type is dynamic, the unique identifier is obtained automatically. If metadata is obtained directly through a network request, what is obtained is template data (without actual data, but only a description of how the interface data is displayed), rather than actual data. Therefore, automated technology is required to load the interface to obtain the webpage code.
[0041] In one embodiment, when using automated technology to obtain a unique identifier, the following process can be used: automatically running the interface document address according to the driving framework to obtain web page code data; parsing the web page code data according to a preset protocol to obtain the unique identifier.
[0042] Specifically, when using a driver framework for automated operation, the automated operation simulates the user opening the interface document. Since the interface webpage is dynamic, the actual opening operation must be performed to obtain the real data, which is also the webpage code data. XPath can then be used to parse the data according to the XML protocol to obtain the unique identifier of the specific HTML tag.
[0043] In one embodiment, obtaining webpage data based on the unique identifier includes executing a tag corresponding to the unique identifier using a driver framework to obtain Markdown-formatted data. Specifically, after determining the unique identifier, i.e., the actual ID of the HTML tag, executing the tag using the driver framework simulates a user clicking the tag, thereby copying data to a clipboard through this execution process. The data clipped to the clipboard is the actual data of the page and is in Markdown format.
[0044] In one embodiment, the generation model class file of json data and annotation description information obtained by parsing web page data includes:
[0045] Step S301: Parse the webpage data to obtain JSON data. Markdown-formatted data clipped to the clipboard is converted into data information required by the class, which is in JSON format. The Markdown protocol can then be used to analyze the data patterns and obtain JSON data. Specifically, when using the Markdown protocol for parsing, each segment in the data is first analyzed based on the segment markers in the Markdown-formatted data to identify the data patterns and determine the JSON data.
[0046] Step S302: Parse the JSON data using a recursive algorithm to obtain the attribute data of the model class and the annotation description information corresponding to each attribute. Specifically, after determining the JSON format of the data, a recursive algorithm can be used to parse different types of JSON data to obtain the attribute data of the model class. Furthermore, when parsing the JSON data, corresponding code can be generated based on the language characteristics of different platforms.
[0047] In one embodiment, the data in the JSON format includes a string type, a dictionary type, and a data type. When the JSON data is in a string type, the attribute data of the model class is generated based on the JSON data. For string types, the attribute data of the model class can be directly generated without using a recursive algorithm.
[0048] When the JSON data is in a dictionary format, a recursive algorithm is used to parse the string type in the dictionary and generate the attribute data of the model class. Specifically, when the data is a dictionary type, the key values in the data can be parsed, and each key value corresponds to an attribute of the model class. For example, the person class has two attributes, name and age. The obtained interface documentation will contain data such as the person class has a key of name and a value of Zhang San. Therefore, when the JSON data is parsed and the key is name, a name data is generated, thus generating code for a name attribute for the person class.
[0049] Model attributes generally consist of three parts: type, attribute name, and attribute annotation. The key value corresponds to the attribute name. The type can be generated from the type annotated in the interface document; the annotation information can be determined by parsing the annotation description information body.
[0050] When the JSON data is in an array format, a recursive algorithm is used to parse it, reducing the array type to a dictionary type. Dictionary parsing is then used to generate the attribute data for the model class. Specifically, for array-type data, the data within the array can be traversed, first using a recursive algorithm to parse the array type into a dictionary type; then, using a recursive algorithm to parse the dictionary type into a string type, the attribute data for the model class can be generated.
[0051] For array-type data, it is a description composed of data of the same type. You can use a list to describe an array. For example, there are three students in a class, which can be described by a list: [Zhang San, Li Si, Wang Wu], where Zhang San is an element, or an item.
[0052] Therefore, when different types of JSON data form the attributes of the model class, the dictionary is a corresponding class, and the array is a collection of corresponding multiple objects (here multiple objects are generated by a class template, such as the three items above, which are all specific objects of the person class).
[0053] Parsing webpage data to obtain annotation description information is accomplished as follows: the annotation description information is provided in the form of a Markdown list, so by parsing the Markdown list, patterns can be found. Then, after determining the various attribute data of the model class, the annotation description information corresponding to the corresponding attribute data can be determined based on the attribute data and the patterns in the annotation description information.
[0054] Step S303: Generate a model class file based on the annotation description information corresponding to each attribute and the preset model template. Specifically, after determining the annotation description information corresponding to each attribute, the model template file corresponding to each platform can be determined based on different platforms, such as the model template file for the iOS platform, the Android platform, or the Java platform. Then, the corresponding model code is generated based on the different platforms to obtain the corresponding model class file.
[0055] In one embodiment, if Figure 4 As shown, the automatic model class file generation method is implemented using the following process: the user enters the URL of the interface document address to be converted into a model class file; the interface document website type is determined to be dynamic; if the website type is dynamic, the interface is loaded using automated technology to obtain the web page code; if the website type is not dynamic or is static, the web page code can be directly obtained; the web page code is parsed to extract the corresponding ID value; the web page data or raw data is obtained by parsing the metadata, and the various attribute data of the model class and the annotation description information corresponding to each attribute data are obtained by parsing the metadata, thereby generating the model class code. The model class file can then be created and the generated model code can be stored.
[0056] The automatic generation method of model class files provided by the embodiment of the present invention combines model class templates of different platforms to generate model files covering multiple platforms such as iOS, Android, and Java, synchronously maintaining data consistency across multiple platforms, effectively solving the problem of multiple platforms maintaining their own model files, and effectively reducing communication costs.
[0057] The embodiment of the present invention also provides a device for automatically generating model class files, such as Figure 5 As shown, the device includes:
[0058] The address acquisition module is used to obtain the interface document address; for specific content, please refer to the corresponding part of the above method embodiment and will not be repeated here.
[0059] The parsing module is used to parse the web page according to the interface document address to obtain a unique identifier; the specific content can be found in the corresponding part of the above method embodiment, which will not be repeated here.
[0060] The identification analysis module is used to obtain json data and annotation description information based on the unique identification analysis; the specific content can be found in the corresponding part of the above method embodiment, which will not be repeated here.
[0061] The model class file generation module is used to generate a model class file based on the json data and annotation description information. The specific content can be found in the corresponding part of the above method embodiment and will not be repeated here.
[0062] The model class file automatic generation device provided by an embodiment of the present invention obtains an interface document address; parses a web page based on the interface document address to obtain a unique identifier; analyzes the web page data based on the unique identifier; and generates a model class file based on the JSON data and annotation description information obtained from the parsed web page data. Thus, the model class file automatic generation device automatically generates the corresponding model class file by entering the interface document address, which is convenient and quick, greatly improving work efficiency. Furthermore, since the annotation description information in the model class file is automatically generated, the error rate is low. Furthermore, when performing updates and iterations, only a new model class file needs to be automatically generated to replace the old one, reducing the writing workload.
[0063] For a detailed description of the functions of the device for automatically generating model class files provided in an embodiment of the present invention, please refer to the description of the method for automatically generating model class files in the above embodiment.
[0064] The embodiment of the present invention also provides a storage medium, such as Figure 6 As shown, a computer program 601 is stored thereon, and when the instructions are executed by the processor, the steps of the method for automatically generating a model class file in the above embodiment are implemented. The storage medium also stores audio and video stream data, feature frame data, interaction request signaling, encrypted data, and preset data size. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk drive (HDD) or a solid-state drive (SSD); the storage medium can also include a combination of the above types of memory.
[0065] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD). The storage medium can also include a combination of the above-mentioned types of memory.
[0066] The embodiment of the present invention further provides an electronic device, such as Figure 7As shown, the electronic device may include a processor 51 and a memory 52, wherein the processor 51 and the memory 52 may be connected via a bus or other means. Figure 7 The bus connection is taken as an example.
[0067] The processor 51 may be a central processing unit (CPU). The processor 51 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0068] Memory 52, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as the corresponding program instructions / modules in the embodiments of the present invention. Processor 51 executes the non-transitory software programs, instructions, and modules stored in memory 52 to perform various processor functions and data processing, thereby implementing the method for automatically generating model class files in the above-mentioned method embodiment.
[0069] The memory 52 may include a program storage area and a data storage area, wherein the program storage area may store applications required for operating the device and at least one function; the data storage area may store data created by the processor 51, etc. In addition, the memory 52 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 embodiments, the memory 52 may optionally include a memory remotely located relative to the processor 51, and these remote memories may be connected to the processor 51 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.
[0070] The one or more modules are stored in the memory 52 and when executed by the processor 51, perform the following steps: Figure 1-4 The model class file automatic generation method in the illustrated embodiment.
[0071] For details of the above electronic equipment, please refer to Figures 1 to 4 The corresponding descriptions and effects in the embodiments shown can be understood and will not be repeated here.
[0072] Although the embodiments of the present invention have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention. Such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for automatically generating a model class file, characterized in that: include: Get the interface document address; Parse the web page according to the interface document address to obtain a unique identifier; Analyze and obtain web page data based on the unique identifier; Generate a model class file based on the json data and annotation description information obtained by parsing the web page data; The webpage data is obtained by analyzing the unique identifier, including: Run the tag corresponding to the unique identifier according to the driving framework to obtain markdown format web page data; The generated model class file of json data and annotation description information obtained by parsing the web page data includes: Parse the web page data to obtain json data; Parse the JSON data according to a recursive algorithm to obtain the attribute data of the model class and the annotation description information corresponding to each attribute; Generate a model class file based on the annotation description information corresponding to each attribute and the preset model template; Parse web page data to obtain annotation description information, which is implemented as follows: the annotation description information of the data is provided in the style of a markdown list. The markdown list is parsed to obtain the patterns therein. After determining the various attribute data of the model class, the annotation description information corresponding to the corresponding attribute data is determined based on the attribute data and the patterns of the annotation description information. Parse the JSON data using a recursive algorithm to obtain the attribute data of the model class and the annotation description information corresponding to each attribute, including: According to the type of JSON data, a recursive algorithm is used to parse it and obtain the attribute data of the model class; Parsing the web page data to obtain annotation description information; Obtain the annotation description information corresponding to each attribute according to the attribute data and annotation description information of the model class; According to the type of JSON data, a recursive algorithm is used to parse it and obtain the various attribute data of the model class, including: When the format of JSON data is string type, generate each attribute data of the model class according to the JSON data; When the format of JSON data is dictionary type, a recursive algorithm is used to parse the string type in the dictionary and generate the attribute data of the model class; When the format of JSON data is array type, a recursive algorithm is used to parse it, reducing the array type to a dictionary type. The dictionary type parsing method is used to generate the attribute data of the model class.
2. The method for automatically generating model class files according to claim 1, characterized in that: Parsing the web page according to the interface document address to obtain a unique identifier includes: Determine the website type according to the interface document address; When the website type is a static type, obtaining the unique identifier according to the interface document address; When the website type is a dynamic type, the unique identifier is obtained in an automated manner.
3. The method for automatically generating model class files according to claim 2, characterized in that: Obtaining the unique identifier in an automated manner includes: Automatically run the interface document address according to the driving framework to obtain web page code data; The webpage code data is parsed according to a preset protocol to obtain the unique identifier.
4. A device for automatically generating model class files, characterized in that: include: Address acquisition module, used to obtain the interface document address; A parsing module, configured to parse a web page according to the interface document address to obtain a unique identifier; An identification analysis module, configured to obtain web page data based on the unique identification analysis; A model class file generation module is used to generate a model class file based on the JSON data and annotation description information obtained by parsing the web page data; The webpage data is obtained by analyzing the unique identifier, including: Run the tag corresponding to the unique identifier according to the driving framework to obtain markdown format web page data; The generated model class file of json data and annotation description information obtained by parsing the web page data includes: Parse the web page data to obtain json data; Parse the JSON data according to a recursive algorithm to obtain the attribute data of the model class and the annotation description information corresponding to each attribute; Generate a model class file based on the annotation description information corresponding to each attribute and the preset model template; Parse web page data to obtain annotation description information, which is implemented as follows: the annotation description information of the data is provided in the style of a markdown list. The markdown list is parsed to obtain the patterns therein. After determining the various attribute data of the model class, the annotation description information corresponding to the corresponding attribute data is determined based on the attribute data and the patterns of the annotation description information. Parse the JSON data using a recursive algorithm to obtain the attribute data of the model class and the annotation description information corresponding to each attribute, including: According to the type of JSON data, a recursive algorithm is used to parse it and obtain the attribute data of the model class; Parsing the web page data to obtain annotation description information; Obtain the annotation description information corresponding to each attribute according to the attribute data and annotation description information of the model class; Use recursive algorithm to parse and obtain various attribute data of the model class, including: When the format of JSON data is string type, generate each attribute data of the model class according to the JSON data; When the format of JSON data is dictionary type, a recursive algorithm is used to parse the string type in the dictionary and generate the attribute data of the model class; When the format of JSON data is array type, a recursive algorithm is used to parse it, reducing the array type to a dictionary type. The dictionary type parsing method is used to generate the attribute data of the model class.
5. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method for automatically generating a model class file according to any one of claims 1 to 3.
6. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for automatically generating a model class file according to any one of claims 1 to 3 by executing the computer instructions.
Citation Information
Patent Citations
Dynamic webpage acquisition method and device
CN101996196A
Code automatic generation method and device, electronic equipment and storage medium
CN109614102A