Method and device for converting self-query data structure into tree data structure, computer readable storage medium and electronic equipment

By converting the table-form interface description document into a tree data structure, the problems of slow development progress and high maintenance costs caused by manual analysis of interface description documents in the prior art are solved, and efficient development and simulation testing are achieved.

CN119759913APending Publication Date: 2025-04-04TRAVELSKY TECHNOLOGY LIMITED
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411958541.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

When the interface method is changed, the existing technology requires manual analysis of interface description documents, resulting in slow development progress, low simulation testing efficiency, and high maintenance costs.

Method used

A method of converting table-form interface description documents into tree data structures is proposed. By obtaining text data of interface description documents, analyzing the basic text structure, building root nodes and child nodes, and using recursive node construction functions to build the next layer of nodes to form a tree data structure.

Benefits of technology

It realizes efficient conversion of table-form interface description documents into tree data structures, improving development efficiency and simulation testing efficiency, and reducing maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759913A_ABST
    Figure CN119759913A_ABST
Patent Text Reader

Abstract

The invention relates to a method and device for converting a self-query data structure into a tree data structure. The method comprises the following steps: acquiring a description document of an external interface, reading text data of the description document of the interface, and analyzing a text basic structure; when an interface request definition is constructed, obtaining a root table id according to a table id tag, and obtaining root node data according to the root table id; obtaining all tables according to tables labels, and circularly traversing all tables to obtain all child node data; then creating a root node; and according to the root table id, the root node and all child node lists, constructing a next layer of nodes by using a recursive node construction function until all nodes corresponding to the request data are constructed, and forming a tree data structure. According to the method, the external interface description document in a table form can be converted into a tree data structure, and the practicability is high; according to the method, a cyclic and recursive implementation mode is adopted, the performance is high, the time complexity is low, and the performance consumption is small.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the technical field of data structure conversion, and in particular, relates to a method, device, computer-readable storage medium and electronic device for converting a self-query data structure into a tree data structure. Background Art

[0002] When the interface method changes, the interface description document needs to be re-parsed. Manual analysis is time-consuming and labor-intensive, and prone to errors, resulting in slow development progress and low simulation test efficiency. In addition, each time a new interface is added, the interface description document must be manually analyzed, and the maintenance cost is too high. Therefore, how to efficiently and automatically parse the interface document into a simple and easy-to-use data structure, reduce maintenance costs, and improve the efficiency of simulation testing is becoming increasingly important.

[0003] The test simulation system TSS (Trusted Platform Module Software Stack, which is the core software component that interacts with the Trusted Platform Module (TPM)) needs to perform interface simulation tests on multiple product applications. Different interface description documents need to be matched during the actual simulation process. However, many product application interface documents are provided in formats such as tables or XML. Interface description documents in tables or XML formats have the disadvantages of structural redundancy, unclear nesting levels, and cumbersome simulation rule implementation. In order to simulate product applications more conveniently and efficiently, it is necessary to develop a conversion device to convert the format of existing interface description documents in tables or XML formats so that the converted interface description documents can be saved in a tree data structure. Since the tree data structure has the advantages of clear structure, distinct parent-child node hierarchy, user-friendliness, and easy post-program processing, the conversion device can be used to perform test simulation development on the converted tree data structure, which can greatly improve development efficiency. Summary of the invention

[0004] In order to address the above-mentioned problems and meet the actual application needs of simulation testing, this application proposes a new method and device for converting a self-query data structure into a tree data structure. This application mainly proposes a solution for converting an interface description document in a tabular format into a tree data structure. The tree data structure is a relatively popular data structure in today's Internet software development. It is widely used and highly practical. It has the advantages of simple expression and clear structure when describing nodes with nested and parent-child relationships. Because most platform product applications use tabular form to provide interface description documents, it is more representative and practical to convert the tabular interface description document into a tree data structure.

[0005] In order to achieve the above objectives, this application provides the following technical solutions:

[0006] A first aspect of the present application provides a method for converting a self-query data structure into a tree data structure, the method comprising:

[0007] Obtain the description document of the external interface, read the text data of the interface description document, and parse the basic structure of the text;

[0008] When building the interface request definition, get the root table id according to the tableid tag, get the root node data according to the root table id; get all tables according to the tables tag, loop through all tables, get all child node data; then create the root node;

[0009] According to the root table ID, the root node and all child node lists, a recursive node construction function is used to build the next layer of nodes until all nodes corresponding to the requested data are built, forming a tree data structure.

[0010] Optionally, in the method of the present application, the interface description document is in a tabular form, and its basic structure includes an interface request definition, a response definition, and an abnormal response definition;

[0011] The method further includes: constructing a tree data structure corresponding to the interface response definition and constructing a tree data structure corresponding to the interface exception response definition.

[0012] Optionally, the method of the present application further includes: looping through all tables, obtaining the sub-node element content of each table, and uniformly saving all the sub-nodes into a sub-node container.

[0013] Optionally, in the method of the present application, the use of a recursive node construction function to construct the next layer of nodes includes:

[0014] If the node type is a basic type node, exit the current recursive level and return to the previous recursive call as a recursive exit;

[0015] If all child nodes of the upper node are built, it will return to its parent node calling layer until it returns to the top node, and the construction is completed.

[0016] Optionally, in the method of the present application, the next layer of nodes is constructed using a recursive node construction function according to the root table ID, the root node and the list of all child nodes, including:

[0017] Get the list of child nodes corresponding to the current node;

[0018] Traverse the child nodes and obtain the basic information of the child nodes;

[0019] Determine whether the current node is an object type. If so, construct an object subnode based on the basic information of the subnode, and then add the object subnode to the properties field of the current node; then recursively construct the subnodes of the properties node; if not, proceed to the next step;

[0020] Determine whether the current node is of array type. If so, construct an array child node based on the basic information of the child node, and then add the array child node to the items field of the current node; then recursively construct the child nodes of the item node and return them.

[0021] A second aspect of the present application provides a device for converting a self-query data structure into a tree data structure, the device comprising:

[0022] Text parsing module: used to obtain the description document of the simulation test interface, read the text data of the interface description document, and parse the basic structure of the text;

[0023] Root node creation module: used to obtain the root table id according to the tableid tag when building the interface request definition, and obtain the root node data according to the root table id; obtain all tables according to the tables tag, loop through all tables, and obtain all child node data; then create the root node;

[0024] Data structure conversion module: used to build the next layer of nodes using a recursive node construction function according to the root table id, the root node and all child node lists, until all nodes corresponding to the requested data are built, forming a tree data structure.

[0025] The device implements the steps of the aforementioned method for converting a self-query data structure into a tree data structure when running.

[0026] Optionally, in the device of the present application, the interface description document is in a tabular form, and its basic structure includes an interface request definition, a response definition, and an abnormal response definition.

[0027] Optionally, in the device of the present application, the data structure conversion module constructs the next layer of nodes using a recursive node construction function according to the root table ID, the root node and the list of all child nodes, including:

[0028] Get the list of child nodes corresponding to the current node;

[0029] Traverse the child nodes and obtain the basic information of the child nodes;

[0030] Determine whether the current node is an object type. If so, construct an object subnode based on the basic information of the subnode, and then add the object subnode to the properties field of the current node; then recursively construct the subnodes of the properties node; if not, proceed to the next step;

[0031] Determine whether the current node is of array type. If so, construct an array child node based on the basic information of the child node, and then add the array child node to the items field of the current node; then recursively construct the child nodes of the item node and return them.

[0032] A third aspect of the present application provides an electronic device, comprising: a memory and a processor;

[0033] Memory: used to store computer programs;

[0034] Processor: used for executing the computer program to implement the steps of the aforementioned method of converting the self-query data structure into a tree data structure.

[0035] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the aforementioned method of converting a self-query data structure into a tree data structure are implemented.

[0036] In summary, this application proposes a new method for converting a self-query data structure into a tree data structure, which has the following advantages:

[0037] (1) This method can convert a tabular external interface description document into a tree data structure, which is highly practical.

[0038] (2) This method uses a loop and recursive implementation method, which has high performance, low time complexity, and low performance consumption.

[0039] (3) After the method converts the tabular data into data of a tree data structure, the data structure is simple, clear, easy to understand, readable, and easy to use.

[0040] (4) This method can obtain the complete tree view of the current node, which solves the problem that some existing methods can only obtain the parent node but cannot obtain the child nodes of the current node, thereby improving the versatility of the technology. In addition, this method adopts a hierarchical bidirectional recursive strategy, which overcomes the deficiency that some existing methods can only search for nodes in a one-way upward direction.

[0041] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the techniques indicated in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0043] Figure 1 A design architecture diagram of a method for converting a self-query data structure into a tree data structure provided in an embodiment of the present application.

[0044] Figure 2 An overall implementation flow chart of the method for converting a self-query data structure into a tree data structure provided in an embodiment of the present application.

[0045] Figure 3 This is a parent-child relationship diagram of nodes in the embodiment method of this application.

[0046] Figure 4 This is the top-level flow chart of the method of the embodiment of the present application.

[0047] Figure 5 This is a schematic diagram of obtaining an interface external ID based on an interface ID in the method of an embodiment of the present application.

[0048] Figure 6 This is a schematic diagram of obtaining interface definition from Redis in the embodiment method of this application.

[0049] Figure 7 The parsing interface in the embodiment method of this application is defined as a JSON array diagram.

[0050] Figure 8 A schematic diagram of a tree data structure corresponding to the interface request definition constructed in the embodiment method of the present application.

[0051] Fig. 9 A schematic diagram of the next layer of nodes defined for recursively constructing an interface in the method of an embodiment of the present application.

[0052] Fig.10 A structural diagram of the composition of an apparatus for converting a self-query data structure into a tree data structure provided in an embodiment of the present application.

[0053] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0055] As used herein, the term “including” and its variations are open inclusions, ie, “including but not limited to”; the term “based on” means “based at least in part on”; and the term “one embodiment” means “at least one embodiment”.

[0056] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as "one or more".

[0057] Embodiment: A method for converting a self-query data structure into a tree data structure

[0058] When an interface needs to be tested and simulated, the description document of the interface needs to be obtained first. Taking the interface description document in tabular form as an example, the text data of the interface description document is first read to parse the basic structure of the text, which generally includes interface request definition, response definition, and exception response definition. Then further parse the above three parts of data respectively. When constructing the interface request data, first obtain the top-level table id according to the tableid (table id) tag, and create a root node based on this. The node type is object type, which serves as the top-level node of the request. Then obtain all tables according to the tables (child table array) tag, and then loop through all tables to obtain the non-empty fields of the child nodes (children) of each table element, and save all child nodes in the child node container (allChildren) uniformly. Finally, according to the root node rootTableid (root table id), the root node and all child node lists, construct the next layer of nodes. In the process of building the next layer of nodes, recursive call logic is used. If the node type is a basic type node (a node whose type field is b), the current recursive level is exited and the recursive call of the previous level is returned as a recursive exit. If all child nodes of the upper node are built, the call layer of its parent node is further returned until it returns to the top node. This construction is completed. At this point, all nodes corresponding to the requested data have been built, and a tree data structure has been formed.

[0059] When traversing the child node fields and constructing child nodes, first obtain the basic type field of the current node, and then perform the following processing according to the type of the current node: (1) If the type of the current node is an object type (a node whose type field is o), first construct a child node (childStruct) based on the basic information, then add it to the properties field of the current node as an attribute field of the current node, and then further construct its child nodes for the childStruct node; (2) If the type of the current node is an array type (a node whose type field is a), first construct an array node (item) based on the basic information, then set it to the items field of the current node, and then further construct its child nodes for the item node.

[0060] There are three types of tree nodes to be constructed: request definition, response definition, and exception response definition. The logic for constructing response definition and exception response definition is similar to the logic for constructing request definition.

[0061] Figure 1 The following is a design framework of the method for converting a self-query data structure into a tree data structure in this application. Figure 2 The overall implementation process of the present application method is shown as follows: Figure 1 and Figure 2 As shown, the method comprises the following steps:

[0062] Obtain the description document of the external interface, read the text data of the interface description document, and parse the basic structure of the text;

[0063] When building the interface request definition, get the root table id according to the tableid tag, get the root node data according to the root table id; get all tables according to the tables tag, loop through all tables, get all child node data; then create the root node;

[0064] According to the root table ID, the root node and all child node lists, a recursive node construction function is used to build the next layer of nodes until all nodes corresponding to the requested data are built, forming a tree data structure.

[0065] In order to better understand the technical solution of the present application, it is further described with reference to the following embodiments.

[0066] This solution takes a table interface description document as an example to implement a method for converting a table description document into a tree data structure.

[0067] The top-level table data sample of the interface description document is as follows:

[0068] serial number Field Name Field Description 1 TableType Table type (values: request, response, exception response) 2 Tableid Table id 3 Tables Subtable Array

[0069] The subtable fields are described as follows:

[0070]

[0071]

[0072] The Children field is described as follows:

[0073] serial number Field Name Field Description 1 ApiId Application ID 2 FieldId Field id 3 NodeType Node type (value: b-basic type, o-object type, a-array type) 4 Tableid Table ID 5 FieldName Node Name 6 DataType Field Type 7 FieldDesc Field Description

[0074] The fields contained in the converted tree node (ApiStruct) are described as follows:

[0075]

[0076] In the above example, the table description document is given in JSON format, and the JSON format request message needs to be formatted. When building, different types of top-level nodes are generated according to the top-level node type requirements. In this example, the top-level node may be a request, a response, or an exception response. A parent node can have multiple child nodes, but a child node can only have one parent node. If the current node is a top-level node, its parent node is empty. In the process of traversing child nodes, they need to be processed separately according to the type of the current parent node. Specifically, if the current node is an object type, a child node object is constructed and then added to the properties field of the ApiStruct object; if the current node is an array type, an array element node object needs to be constructed first, and then the array element node is added to the items field. If the child node type does not belong to the basic type, it is further recursed downward until the child node is of the basic type, and then the recursion ends, and it is rolled back upward in sequence, and finally rolled back to the call of the top-level node. At this point, the construction of the entire tree node structure is completed. The parent-child relationship of the node is as follows Figure 3 shown.

[0077] The process of converting to a tree data structure is as follows:

[0078] First, read the external interface definition, verify the definition data, and convert it into a JSON array after verification. Then loop through the JSON array and divide the elements into three categories according to the type of array objects, namely request definition, response definition, and response exception definition. Then build a tree data structure for the above three parts respectively.

[0079] When building a tree data structure, first get the root table id (rootTableid) according to the tableid tag, and get all tables according to the tables tag. Because there is a parent-child relationship between tables, get the children element content of each table and put it into the allChildren list. Then create a root node (struct), pass the root node, the previously obtained root table id (rootTableid) and all child nodes (allChildren) as parameters to the recursive node construction function (buildStruct()), and wait for the recursive construction function call to return, and you can get the tree data structure corresponding to the interface definition.

[0080] Figure 4 The top-level process in the method of the embodiment of the present application is shown, including:

[0081] Get the interface external id based on the interface id;

[0082] Get the external interface definition based on the interface external id;

[0083] Parse the external interface definition as a Json array;

[0084] According to the Json array element type, the interface request definition is grouped;

[0085] Recursive calls are made to build the interface definition tree data structure.

[0086] Figure 5 The method of obtaining the interface external ID according to the interface ID in the embodiment of the present application includes:

[0087] Get interface details based on interface id;

[0088] Determine whether the interface details information exists. If so, it will prompt that the interface details are found; if not, it will return the interface external ID.

[0089] Figure 6 The method of obtaining the interface definition from Redis in the embodiment of the present application includes:

[0090] Pass in the external interface id and fieldJson field name;

[0091] Read the interface definition stored in the readis cache map;

[0092] Returns the interface definition.

[0093] Figure 7 The parsing interface in the method of the embodiment of the present application is defined as a JSON array, including:

[0094] Read interface definition text data;

[0095] Determine whether the definition content is empty. If so, it prompts that the definition content is empty. If not, parse the text data into a Json array.

[0096] Figure 8 The tree data structure corresponding to the interface request definition constructed in the method of the embodiment of the present application is shown, including:

[0097] Get the root table id based on tableid;

[0098] Get all tables according to the tables tag;

[0099] Get the root node data according to the root table id;

[0100] Get all child node data;

[0101] Construct the root node;

[0102] Recursively build the next layer of nodes.

[0103] Because the node construction function is a recursive function, it is the key part of the whole solution and its internal implementation is relatively complex, so it is further explained here.

[0104] Fig. 9 The diagram shown is a schematic diagram of recursively constructing a node of the next layer of interface definition in the method of the embodiment of the present application, including:

[0105] Get the list of child nodes corresponding to the current node;

[0106] Traverse the child nodes;

[0107] Get basic information of child nodes;

[0108] Determine whether the current node is an object. If so, construct the object child node based on the basic information of the child node and add it to the properties field of the current node; then recursively construct the object child node and return it; if not, proceed to the next step;

[0109] Determine whether the current node is an array. If so, construct an array child node based on the basic information of the child node and add it to the items field of the current node; then recursively construct the array child node and return it.

[0110] Specifically, first determine whether the current node is a basic type node (a field of type b). If it is a basic type node, there will be no child nodes, and this is the recursive exit.

[0111] If the current node is not a basic type node, loop through its child nodes, first obtain the basic information of the child nodes, and then determine the type of the current node: (1) If the current node type is an object (type is o), construct a child node object (childStruct), add the child node to the properties collection of the current node, and save it as an attribute of the current node; then take the child node (childStruct), all table child node collections (allNodes) and the child node table id (tableid) as parameters, recursively call the node construction function again, and enter the next round of recursion. At this time, the child node is used as the current node, and the child node collection under it is further determined, and the properties combination or items element is set for it, until the construction function is finally entered to determine whether the current node in this round of recursion is a basic type node, and then fall back to the previous layer of call. (2) If the current node is an array type node (type is a), then construct an array node (item) and set it as the items attribute of the current node; then take the array node (item), all table child node sets (allNodes) and the child node table id (tableid) as parameters, recursively call the node construction function again, and enter the next round of recursion. At this time, the child node is used as the current node, and the child node set under it is further determined, and the properties combination or items element is set for it, until the construction function is finally entered to determine whether the current node of this round of recursion is a basic type node, and then fall back to the previous layer of call.

[0112] When the outermost child node loop is completed, the tree data structure of this part is created.

[0113] Fig.10 The structure of the device for converting a self-query data structure into a tree data structure provided by an embodiment of the present application is shown, and the device includes:

[0114] Text parsing module: used to obtain the description document of the simulation test interface, read the text data of the interface description document, and parse the basic structure of the text;

[0115] Root node creation module: used to obtain the root table id according to the tableid tag when building the interface request definition, and obtain the root node data according to the root table id; obtain all tables according to the tables tag, loop through all tables, and obtain all child node data; then create the root node;

[0116] Data structure conversion module: used to build the next layer of nodes using a recursive node construction function according to the root table id, the root node and all child node lists, until all nodes corresponding to the requested data are built, forming a tree data structure.

[0117] When the above device is running, the steps of the method for converting a self-query data structure into a tree data structure disclosed in the present application are implemented.

[0118] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the device, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be realized by a special hardware-based system that performs the specified function or operation, or can be realized by a combination of special hardware and computer instructions.

[0119] like Fig.11 As shown, the embodiment of the present application also discloses an electronic device, including: a processor 310, a communication interface 320, a memory 330 for storing a computer program executable by the processor, and a communication bus 340. The processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 runs the executable computer program to implement the steps of the method of converting the self-query data structure into the tree data structure.

[0120] It is understandable that, in addition to the memory and the processor, the electronic device may also include an input device such as a keyboard, an output device such as a display, and other communication modules. The input device, the output device, and other communication modules communicate with the processor via an I / O interface (i.e., an input / output interface).

[0121] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0122] Furthermore, the present application also discloses a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device can execute the various steps of the method disclosed in the present application for converting a self-query data structure into a tree data structure.

[0123] In the context of the present application, a computer-readable storage medium may be a tangible medium, more specific examples of which would include a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0124] In particular, according to an embodiment of the present application, the process described in the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method of converting a self-query data structure into a tree data structure disclosed in the present application. When the computer program is executed by a processing device, the above functions defined in the method of the embodiment of the present application are executed.

[0125] Although several specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present application. The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solutions formed by a specific combination of the above technical features, but also should cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above public concept.

[0126] Those skilled in the art should also understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A method for converting a self-query data structure into a tree data structure, characterized in that: The method comprises: Obtain the description document of the external interface, read the text data of the interface description document, and parse the basic structure of the text; When building the interface request definition, get the root table id according to the tableid tag, get the root node data according to the root table id; get all tables according to the tables tag, loop through all tables, get all child node data; then create the root node; According to the root table ID, the root node and all child node lists, a recursive node construction function is used to build the next layer of nodes until all nodes corresponding to the requested data are built, forming a tree data structure.

2. The method according to claim 1, characterized in that The interface description document is in a tabular form, and its basic structure includes interface request definition, response definition, and abnormal response definition; The method further includes: constructing a tree data structure corresponding to the interface response definition and constructing a tree data structure corresponding to the interface exception response definition.

3. The method according to claim 1, characterized in that The method further includes: looping through all tables, obtaining the sub-node element content of each table, and uniformly saving all the sub-nodes into a sub-node container.

4. The method according to claim 1, characterized in that: The recursive node construction function is used to construct the next layer of nodes, including: If the node type is a basic type node, exit the current recursive level and return to the previous recursive call as a recursive exit; If all child nodes of the upper node are built, it will return to its parent node calling layer until it returns to the top node, and the construction is completed.

5. The method according to claim 1, characterized in that The next layer of nodes is constructed using a recursive node construction function according to the root table ID, the root node and all child node lists, including: Get the list of child nodes corresponding to the current node; Traverse the child nodes and obtain the basic information of the child nodes; Determine whether the current node is an object type. If so, construct an object subnode based on the basic information of the subnode, and then add the object subnode to the properties field of the current node; then recursively construct the subnodes of the properties node; if not, proceed to the next step; Determine whether the current node is of array type. If so, construct an array child node based on the basic information of the child node, and then add the array child node to the items field of the current node; then recursively construct the child nodes of the item node and return them.

6. A device for converting a self-query data structure into a tree data structure, characterized in that: The device comprises: Text parsing module: used to obtain the description document of the simulation test interface, read the text data of the interface description document, and parse the basic structure of the text; Root node creation module: used to obtain the root table id according to the tableid tag when building the interface request definition, and obtain the root node data according to the root table id; obtain all tables according to the tables tag, loop through all tables, and obtain all child node data; then create the root node; Data structure conversion module: used to build the next layer of nodes using a recursive node construction function according to the root table id, the root node and all child node lists, until all nodes corresponding to the requested data are built, forming a tree data structure.

7. The device according to claim 6, characterized in that The interface description document is in a table format, and its basic structure includes interface request definition, response definition, and abnormal response definition.

8. The device according to claim 6, characterized in that The data structure conversion module constructs the next layer of nodes using a recursive node construction function according to the root table ID, the root node and all child node lists, including: Get the list of child nodes corresponding to the current node; Traverse the child nodes and obtain the basic information of the child nodes; Determine whether the current node is an object type. If so, construct an object subnode based on the basic information of the subnode, and then add the object subnode to the properties field of the current node; then recursively construct the subnodes of the properties node; if not, proceed to the next step; Determine whether the current node is of array type. If so, construct an array child node based on the basic information of the child node, and then add the array child node to the items field of the current node; then recursively construct the child nodes of the item node and return them.

9. 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 for converting a self-query data structure into a tree data structure according to any one of claims 1 to 5 are implemented.

10. An electronic device, characterized in that: include: Memory and processor; Memory: used to store computer programs; Processor: used to execute the computer program to implement the steps of the method for converting a self-query data structure into a tree data structure according to any one of claims 1 to 5.

Citation Information

Cited By

  • Data screening method, device and product

    CN120448386A