Local interface data update methods, devices, equipment, media and products
By converting key-value pairs into a corpus chain structure and using automated tools to compare the structural similarity between local interface data and the latest interface data, the problem of lagging interface format updates is solved, achieving efficient automated updates and high accuracy.
Patent Information
- Application Number
- CN202511248796.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-03
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2045-09-03
AI Technical Summary
In a front-end and back-end separated development model, due to the uncertainty of requirements and changes in tasks, the interface format cannot be updated in real time, resulting in local interface updates being delayed, inefficient, requiring manual modification, and consuming a lot of time and effort.
By extracting key names and value types, key-value pairs are converted into a corpus chain structure. Automated tools are used to compare the structural similarity between local interface data and the latest interface data to achieve automated updates. Build tools such as Webpack or Gulp are used to automatically perform data comparison and updates during the build process.
It improves data update efficiency, reduces human error, lowers maintenance and repair costs, and achieves automated updates and accuracy of local interface data.
Smart Images

Figure CN120763188B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of software engineering technology, and in particular to a method, apparatus, device, medium and product for updating local interface data. Background Technology
[0002] In a front-end / back-end separated development model, the front-end and back-end typically agree on an interface format. The front-end then manually configures its local interface based on this agreed-upon format, calling the local server through the interface to achieve front-end development independent of the back-end. However, in actual development, due to uncertainties such as the nature of requirements and changes in development tasks, the agreed-upon interface format often cannot be synchronized with the actual code in real time, thus requiring frequent updates.
[0003] In order to keep the local interface in line with the actual development progress, the local interface must also be modified when the interface format is updated. However, most of the relevant technologies involve manual modification, which requires a lot of time and effort and is inefficient, causing the local interface update to often lag behind the actual development progress. Summary of the Invention
[0004] In view of the above problems, this disclosure is made to provide a method, apparatus, device, medium and product for updating local interface data.
[0005] According to one aspect of this disclosure, a method for updating local interface data is provided, comprising:
[0006] Obtain local interface data and the latest interface data; wherein, the local interface data is simulated data used to simulate backend interface behavior, and the latest interface data is obtained based on the backend server, and the local interface data and the latest interface data include multiple key-value pairs;
[0007] Extract the corpus from the local interface data and the latest interface data respectively; wherein, the corpus includes key names and the value types corresponding to the key names, and the value types are the data structures to which the values corresponding to the key names belong;
[0008] Based on the corpus in the local interface data, a first corpus chain structure is generated, and based on the corpus in the latest interface data, a second corpus chain structure is generated; wherein, the first corpus chain structure is used to characterize the hierarchical relationship between the corpora in the local interface data, and the second corpus chain structure is used to characterize the hierarchical relationship between the corpora in the latest interface data.
[0009] Based on the value types included in the corpus, each corpus in the first corpus chain structure and the second corpus chain structure is compared to obtain the comparison result;
[0010] Based on the comparison results, the local interface data is updated.
[0011] By extracting key names and value types, key-value pairs are transformed into a corpus chain structure with distinct comparison features. This eliminates the need to consider the specific content of the keys and values or the order of the key-value pairs; simply comparing the structural similarity between local and latest interface data yields the comparison results. This facilitates identifying the differences between local and latest interface data to the greatest extent possible, enabling automatic updates of local interface data and improving data update efficiency. Automation of this disclosure can be achieved through scripting or using automation tools, such as Webpack and Gulp, to automatically perform data comparison and update operations during the build process. Compared to manual updates, this reduces human error and lowers maintenance and repair costs.
[0012] Furthermore, according to a local interface data update method of one aspect of this disclosure, the step of comparing each corpus in the first corpus chain structure and the second corpus chain structure according to the value type included in the corpus to obtain a comparison result includes:
[0013] Based on the value types included in the corpus, identify the corpus processing unit corresponding to each corpus in the first corpus chain structure and the second corpus chain structure;
[0014] The corpora in the first corpus chain structure are combined with the corpora in the second corpus chain structure to obtain multiple corpus combinations;
[0015] The similarity of each combination of corpora is calculated by the corpus processing unit;
[0016] The comparison result is obtained based on the combination of corpora with the highest similarity.
[0017] By abstracting corpus processing units using value types, and having these units calculate the similarity of corresponding corpora according to the principle of maximizing similarity, a combination of divide-and-conquer and parallel processing is achieved, which helps improve computational efficiency. By calculating similarity and presenting the comparison results as quantified data, the differences in the data can be identified to the greatest extent possible, thus improving the accuracy of the comparison results.
[0018] Furthermore, according to one aspect of the local interface data update method of this disclosure, the corpus processing unit includes at least one of a basic structure processing unit, an array processing unit, and an object processing unit;
[0019] The step of determining the corpus processing unit corresponding to each corpus in the first corpus chain structure and the second corpus chain structure based on the value types included in the corpus includes:
[0020] Obtain the first corpus, the second corpus, and the third corpus from the first corpus chain structure and the second corpus chain structure; wherein, the first corpus includes the corpus with the value type as the basic structure, the second corpus includes the corpus with the value type as an array, and the third corpus includes the corpus with the value type as an object, wherein the basic structure represents the smallest indivisible hierarchical unit of the value, and the object represents the value as a plurality of key-value pairs;
[0021] The corpus processing unit corresponding to the first corpus is confirmed to be the basic structure processing unit, the corpus processing unit corresponding to the second corpus is confirmed to be the array processing unit, and the corpus processing unit corresponding to the third corpus is confirmed to be the object processing unit.
[0022] Three types of corpus processing units are defined based on value types: basic structure processing unit, array processing unit, and object processing unit. The array processing unit and object processing unit do not perform downward calculations. Elements in the array or key-value pairs in the object are assigned to the corresponding corpus processing unit for calculation based on the data structure in the downwardly split corpus chain structure. These three corpus processing units work collaboratively in parallel, improving the efficiency of similarity calculation and front-end development.
[0023] Furthermore, according to a local interface data update method of one aspect of this disclosure, the step of combining each corpus in the first corpus chain structure with each corpus in the second corpus chain structure to obtain multiple corpus combinations includes:
[0024] Based on the hierarchical relationship in the first corpus chain structure and the second corpus chain structure, each corpus in the first corpus chain structure is combined with each corpus in the second corpus chain structure to obtain multiple initial corpus combinations; wherein, each initial corpus combination includes two corpora.
[0025] Obtain the target corpus combination from the initial corpus combination, and use the target corpus combination as the corpus combination; wherein, the target corpus combination consists of two corpora that have the same value type.
[0026] If the value types of the corpora are different, it means that the data structures of the two corpora are inherently different, and their similarity will definitely be 0. By filtering out the target corpus combinations from the initial corpus combinations and eliminating corpus combinations with different value types, we can reduce the computational load of the corpus processing unit and improve computational efficiency.
[0027] Furthermore, according to a local interface data update method of one aspect of this disclosure, the calculation of the similarity of each of the corpus combinations by the corpus processing unit includes:
[0028] If the value type corresponding to the corpus included in the corpus combination is a basic structure, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent; wherein, the basic structure represents the smallest indivisible hierarchical unit of the value.
[0029] If the key names are the same, the similarity of the corpus combination is equal to the maximum value; if the key names are different, the similarity of the corpus combination is equal to 0.
[0030] When the value type of the corpus is the basic structure, if the key names are the same, even if the specific content of the values changes, the similarity between the two can be considered to be at its maximum value, such as 1. For example, if the basic structure (value type) is string, corpus A = (name, string), and corpus B = (name, string), then the similarity between corpus A and corpus B is equal to 1. Even if the value of corpus A is "BeJson" and the value of corpus B is "David", the similarity between corpus A and corpus B is still considered to be 1. This helps reduce the amount of content that needs to be updated and improves data update efficiency.
[0031] Furthermore, according to a local interface data update method of one aspect of this disclosure, the calculation of the similarity of each of the corpus combinations by the corpus processing unit includes:
[0032] If the value type corresponding to the corpus included in the corpus combination is an object, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent; wherein, the object represents that the value includes multiple key-value pairs;
[0033] If the key names are inconsistent, the similarity of the corpus combinations is equal to 0;
[0034] If the key names are consistent, obtain the sub-corpora included in each of the corpora in the corpus combination, group each of the sub-corpora into multiple sub-corpus combinations, and calculate the similarity of each of the sub-corpus combinations through the corpus processing unit;
[0035] The similarity of the corpus combinations is calculated based on the similarity of the sub-corpus combinations.
[0036] When the value type corresponding to the corpus is an object, it means that the corpus also includes subcorpora. By calculating the similarity of the combination of subcorpora, the similarity of the combination of corpora can be calculated according to the hierarchical relationship, which helps to improve the accuracy of similarity calculation.
[0037] Furthermore, according to a local interface data update method of one aspect of this disclosure, the calculation of the similarity of each of the corpus combinations by the corpus processing unit includes:
[0038] If the value type corresponding to the corpus included in the corpus combination is an array, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent;
[0039] If the key names are inconsistent, the similarity of the corpus combination is 0; if the key names are consistent, virtual key names are generated for the internal elements of the first array and the second array; wherein, the first array is the value corresponding to the corpus belonging to the first corpus chain structure in the corpus combination, and the second array is the value corresponding to the corpus belonging to the second corpus chain structure in the corpus combination.
[0040] Associating the data structure corresponding to each of the internal elements with the virtual key name generates multiple virtual corpora;
[0041] The virtual corpus in the first array is combined with the virtual corpus in the second array to obtain multiple sub-corpus combinations, and the similarity of each sub-corpus combination is calculated by the corpus processing unit.
[0042] The similarity of the corpus combinations is calculated based on the similarity of the sub-corpus combinations.
[0043] As a special data structure, arrays can contain any JSON structure. By generating virtual keys for the internal elements of an array, it is equivalent to setting unique identifiers for the internal elements. Through the virtual keys, the internal elements can be further transformed into a corpus chain structure according to hierarchical relationships, and then the similarity of the sub-corpus combinations can be calculated.
[0044] Furthermore, according to a local interface data update method of one aspect of this disclosure, calculating the similarity of the corpus combination based on the similarity of the sub-corpus combination includes:
[0045] If the key names are the same, the corpus combination is assigned a score of a; if the corpus combinations include corpora with the same value type, the corpus combination is assigned a score of b.
[0046] The corpus combination is assigned a score of c based on the maximum similarity of the sub-corpus combination;
[0047] Adding a, b, and c together yields the similarity of the corpus combination.
[0048] By setting multiple scoring criteria, the similarity of the corpus combinations is calculated from multiple perspectives. For example, the similarity range can be set to [0,1], where 0 represents completely different corpora (possibly due to added or deleted data), 1 represents consistent corpora, and data between 0 and 1 represents some inconsistencies, marked as modified data. By quantifying the comparison results, the differences between the data can be identified to the greatest extent possible.
[0049] Furthermore, according to a local interface data update method of one aspect of this disclosure, the calculation of the similarity of each of the sub-corpus combinations by the corpus processing unit includes:
[0050] Based on the value type corresponding to each of the sub-corpus combinations, determine the corpus processing unit corresponding to each of the sub-corpus combinations;
[0051] The corpus processing unit calculates the similarity of each sub-corpus combination by comparing the key names and value types in each sub-corpus combination.
[0052] When calculating the similarity of sub-corpus combinations, the same method is used: by determining the value type of the sub-corpus, the sub-corpus combinations are assigned to the corresponding corpus processing units for calculation, thus combining divide-and-conquer with parallel processing to improve computational efficiency.
[0053] Furthermore, according to a local interface data update method of one aspect of this disclosure, updating the local interface data based on the comparison result includes:
[0054] Based on the comparison results, the data to be updated in the local interface data is confirmed; wherein, the data to be updated includes at least one of newly added data, deleted data, and modified data;
[0055] The local interface data is updated based on the data to be updated.
[0056] The data to be updated allows for targeted updates to local interface data. Compared to the overlay updates commonly used in related technologies, this not only saves time and effort but also leaves a trace of the changes to local interface data, enabling the tracking of modification records.
[0057] Furthermore, the local interface data update method according to one aspect of this disclosure also includes:
[0058] According to the pre-agreed interface format between the front-end and the back-end, the local interface data is generated, and a local interface is created based on the local interface data; wherein, the local interface is used to simulate the behavior of the back-end interface, the back-end interface is used to call the back-end server, and the local interface is used to call the front-end local server;
[0059] During the development of the front-end, if a data request is received from the front-end, the current development mode is identified; wherein, the current development mode is used to determine the server that the front-end needs to call.
[0060] If the current development mode is local development mode, send the data request to the local interface to invoke the front-end local server;
[0061] If the current development mode is proxy development mode, send the data request to the backend interface to invoke the backend server.
[0062] By using a predefined interface format, developers can write simulation rules and manually create local interface data, which is the local development mode. In local development mode, front-end developers can simulate the behavior of back-end interfaces in their local development environment without waiting for the back-end service to complete. This helps to speed up the front-end development process and makes the development process more independent and flexible.
[0063] According to another aspect of this disclosure, a local interface data update apparatus is provided, comprising:
[0064] The data acquisition module is used to acquire local interface data and the latest interface data; wherein, the local interface data is simulated data used to simulate the behavior of the backend interface, and the latest interface data is obtained based on the backend server, and the local interface data and the latest interface data include multiple key-value pairs;
[0065] The corpus extraction module is used to extract corpora from the local interface data and the latest interface data respectively; wherein, the corpus includes key names and value types corresponding to the key names, and the value type is the data structure to which the value corresponding to the key name belongs;
[0066] A corpus chain structure generation module is used to generate a first corpus chain structure based on the corpus in the local interface data, and to generate a second corpus chain structure based on the corpus in the latest interface data; wherein, the first corpus chain structure is used to characterize the hierarchical relationship between the corpora in the local interface data, and the second corpus chain structure is used to characterize the hierarchical relationship between the corpora in the latest interface data.
[0067] The comparison module is used to compare each of the corpora in the first corpus chain structure and the second corpus chain structure according to the value types included in the corpus, and obtain the comparison result;
[0068] An update module is used to update the local interface data based on the comparison results.
[0069] According to another aspect of this disclosure, a computer device is provided, including a memory, a processor, and a computer program stored in the memory, the processor executing the computer program to implement the method of one aspect above.
[0070] According to another aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the method of one aspect above.
[0071] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method of the above-described aspect.
[0072] It should be understood that both the foregoing general description and the following detailed description are exemplary and intended to provide further illustration of the claimed technology. Attached Figure Description
[0073] The above and other objects, features, and advantages of this disclosure will become more apparent from the more detailed description of the embodiments thereof in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of this disclosure and form part of the specification. They are used together with the embodiments of this disclosure to explain the disclosure and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same components or steps.
[0074] Figure 1 This is an architectural diagram illustrating a local interface data update method for an application according to an embodiment of this disclosure.
[0075] Figure 2 This is a diagram illustrating the corpus chain structure of an application according to an embodiment of this disclosure.
[0076] Figure 3 The diagram illustrates the corpus chain structure after conversion according to Table 4 of the embodiments of this disclosure.
[0077] Figure 4 This is a flowchart illustrating a local interface data update method for an application according to an embodiment of this disclosure.
[0078] Figure 5 This is a schematic diagram illustrating the structure of a local interface data update apparatus according to an embodiment of the present disclosure.
[0079] Figure 6 This is a schematic diagram illustrating the structure of a computer device according to an embodiment of the present disclosure.
[0080] Figure 7 This is a schematic diagram illustrating a computer program product according to an embodiment of the present disclosure. Detailed Implementation
[0081] To make the objectives, technical solutions, and advantages of this disclosure more apparent, exemplary embodiments according to this disclosure will now be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this disclosure, and not all embodiments of this disclosure. It should be understood that this disclosure is not limited to the exemplary embodiments described herein.
[0082] In a front-end / back-end separated development model, the front-end and back-end typically agree on an interface format. The front-end then manually configures its local interface based on this agreed-upon format, calling the local server through the interface to achieve front-end development independent of the back-end. However, in actual development, due to uncertainties such as the nature of requirements and changes in development tasks, the agreed-upon interface format often cannot be synchronized with the actual code in real time, thus requiring frequent updates.
[0083] In order to keep the local interface in line with the actual development progress, the local interface must also be modified when the interface format is updated. However, most of the relevant technologies involve manual modification, which requires a lot of time and effort and is inefficient, causing the local interface update to often lag behind the actual development progress.
[0084] The above description, with reference to the accompanying drawings, illustrates a local interface data update method, apparatus, device, medium, and product according to embodiments of the present disclosure. By extracting key names and value types, unordered key-value pairs are converted into a corpus chain structure with distinct comparison features. This eliminates the need to consider the specific content of the keys and values or the order of the key-value pairs; only the structural similarity between the local interface data and the latest interface data needs to be compared to obtain the comparison results. This maximizes the identification of differences between the local and latest interface data, achieving automated updates to the local interface data and improving data update efficiency. Automation of the present disclosure can be achieved by writing scripts or using automation tools. For example, build tools such as Webpack and Gulp can be used to automatically perform data comparison and update operations during the build process.
[0085] To facilitate understanding of this embodiment, a local interface data update method disclosed in this disclosure will first be described in detail. The execution entity of the local interface data update method provided in this disclosure is generally a computer device with certain computing capabilities. This computer device may include, for example, a terminal device, a server, or other processing devices. The terminal device may be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. In some possible implementations, this local interface data update method can be implemented by the processor calling computer-readable instructions stored in memory.
[0086] like Figure 1 The diagram shown is an architecture diagram of the local interface data update method provided in this embodiment of the disclosure, including an interface data localization module 1, a comparison module 2, and an update module 3. Specifically:
[0087] Interface Data Localization Module 1: The front-end and back-end agree on the interface format. Based on the Swagger standard format or interface documentation, developers can write mock rules according to the interface format to manually create mock data, i.e., local interface data. Alternatively, mock data can be automatically generated by the interface documentation tool. The specific source of mock data can be selected according to actual needs. This embodiment does not impose any restrictions.
[0088] The development mode that uses mock data instead of real data is called the local development mode. In local development mode, the front-end's local interface can simulate the behavior of the back-end interface in the front-end development environment. That is, the front-end obtains the required data from the local server by calling the local interface, without waiting for the back-end service to complete. This helps to speed up the front-end development process and makes the development process more independent and flexible. When the front-end needs to interact with the actual back-end, it needs to switch from mock data to obtaining real data from the back-end server. At this time, it switches from local development mode to proxy development mode.
[0089] Comparison Module 2: This module activates comparison mode when the developed application starts or is updated. In comparison mode, it supports automatic comparison of interfaces across different iterations and generates change records. Specifically, it includes the following steps:
[0090] Step 1: Obtain the latest API data from the backend server and obtain local API data.
[0091] Among them, the latest interface data and the local interface data are both JSON structures. There are three types of data structures in the JSON structure: (1) basic structure, namely data units such as strings and numbers; (2) array, whose internal elements can be composed of any JSON structure; (3) object, which is a list of key-value pairs, and the value can also be composed of any JSON structure.
[0092] Step 2: Establish the relationship between interface data and corpus to generate a corpus chain structure.
[0093] Table 1 shows the tree structure of the JSON data.
[0094] Table 1. Tree structure of JSON data
[0095]
[0096] As can be seen from the tree structure of the text description examples in Table 1, JSON data contains a certain hierarchical relationship. Therefore, according to the organization method and hierarchical relationship, the local interface data and the latest interface data can be converted into a corpus chain structure with the corpus as the basic unit.
[0097] As shown in Table 2, the corpus consists of two parts: key name and value type. The value type is the data structure corresponding to the value, such as basic structure, array or object.
[0098] Table 2. Corpus Composition Table
[0099]
[0100] Corresponding to the tree structure in the example above, such as Figure 2 The diagram shown is a chain-like structure diagram of the corpus. Figure 2 As can be seen, JSON data is essentially an unordered collection of key-value pairs. In the corpus chain structure, this embodiment only extracts the data structure corresponding to the key name and value. It is insensitive to the specific key-value content and the order of the key-value pairs. There is no need to consider whether the key-value content is consistent or to care about the order of the key-value pairs. In addition, in the corpus chain structure, arrays are special data structures, and their internal elements can be any JSON structure. Due to the characteristics of arrays themselves, internal elements do not have keys. Therefore, this embodiment generates a virtual key for each internal element according to specific rules. The internal elements are then further converted into the corpus chain structure according to their corresponding organization and hierarchical relationship.
[0101] This embodiment also abstracts three types of corpus processing units based on the data structure: basic structure processing unit, array processing unit, and object processing unit. There is a one-to-one correspondence between the corpus processing units and the data structures. For example, the basic structure processing unit is only responsible for calculating the similarity of basic structure corpora such as strings and numbers; the array processing unit is only responsible for calculating the similarity of array corpora; and the object processing unit is only responsible for calculating the similarity of object corpora. Furthermore, the array processing unit and the object processing unit do not perform downward calculations. The internal elements of the array or the key-value pairs in the object can be assigned to the corresponding corpus processing unit for calculation according to the corresponding data structure in the downwardly split corpus chain structure. The entire corpus chain structure is divided into many small blocks, and these small block tasks are assigned to the corresponding corpus processing units for parallel computation.
[0102] Step 3: The corpus processing unit calculates the similarity based on the maximum similarity strategy and obtains the comparison results.
[0103] This embodiment defines the similarity of the comparison results by setting a similarity score. Specifically, the similarity range can be set to [0,1]. 0 represents completely different comparison elements, which may be marked as added or deleted data; 1 represents completely identical comparison elements, which will be marked as matched; and values between 0 and 1 represent partially identical comparison elements, which will be marked as modified data. The comparison elements can be corpora, arrays, objects, or key-value pairs, depending on the specific comparison content.
[0104] For ease of understanding, this embodiment provides the following similarity calculation rules. The score settings can be selected or adjusted according to actual needs, and this embodiment does not impose any restrictions:
[0105] (1) For corpora whose value types are all basic structures, the basic structure processing unit is responsible for calculation. If the key names are the same, the similarity between the two is 1, otherwise it is 0.
[0106] (2) For corpora whose value types are all arrays or all objects, the array processing unit or object processing unit is responsible for calculation. If the key names are the same, the score is 0.3, otherwise it is 0; if the value types are the same, the score is 0.3, otherwise it is 0; if both the key names and value types are the same, since arrays or objects also include multiple sub-elements, it is also necessary to judge the differences between the specific contents of the values. Here, the score range is between 0 and 0.4 (inclusive). Finally, the scores are added together to obtain the similarity.
[0107] Specifically, the formula for calculating similarity is as follows:
[0108]
[0109] Where i and j are comparison elements from different rows and columns.
[0110] Taking arrays as an example, suppose we want to compare array A (A1, A2, A3, A4) and array B (B1, B2, B3, B4). We calculate the similarity of each combination by permuting (A1, A2, A3, A4) and (B1, B2, B3, B4) according to the similarity calculation formula. Table 3 shows the similarity scores between array A and array B.
[0111] Table 3. Similarity scores between array A and array B
[0112]
[0113] As shown in Table 3, the combination with the highest similarity is found. Suppose that (A1, B1), (A2, B2), (A3, B3), and (A4, B4) have the highest similarity. Then, the similarity between array A and array B can be determined based on the similarity of this combination.
[0114] Step 4: Update the local interface data based on the comparison results.
[0115] Specifically, only the changed parts can be updated, rather than overwriting the entire local interface data. This helps reduce unnecessary data processing, improves data update efficiency, and leaves a record of interface changes as the version iterates.
[0116] Based on the above embodiments, this embodiment provides the following application example.
[0117] Table 4 shows a comparison of JSON data:
[0118] Table 4: Comparison of JSON Data
[0119]
[0120] Convert the local interface data A and the latest interface data B in Table 4 into a corpus chain structure, such as... Figure 3 As shown in Table 4, the corpus chain structure diagram after conversion includes corpus (A1, A2, A3, A4) and corpus (B1, B2, B3, B4, B5).
[0121] refer to Figure 3 The similarity calculation process includes the following steps:
[0122] Step 1: The array processing unit detects that two large objects (local interface data and latest interface data) need to be compared, and begins to traverse the corpus within them.
[0123] Step 2: Compare the data recursively by level. First, compare the data in corpora A1 and B1. We find that their value types are both strings, which belong to the basic structure. So we create two new basic structure processing units and let them process A1 and B1 respectively, and wait for them to return the similarity between A1 and B1.
[0124] The comparison process between corpora A1 and (B2, B3, B4, B5) is similar and will not be repeated in this embodiment. Calculations show that the similarity (A1, B2) = 1, the similarity (A2, B3) = 1, and the similarity (A3, B4) = 1.
[0125] For corpora A4 and B5, A4 and B5 have the same key name and a score of 0.3. Both are objects and have a score of 0.3. The object processing unit is then called to process A4 and B5. When the object processing unit starts working, it finds that the values of A4 include (A4.1, A4.2, A4.3) and the values of B5 include (B5.1, B5.2, B5.3, B5.4) in a hierarchical recursive manner. Similarly, (A4.1, A4.2, A4.3) and (B5.1, B5.2, B5.3, B5.4) are compared hierarchically. Taking A4.1 and B5.1 as examples, their value types are both strings, which belong to the basic structure. Therefore, the basic structure processing unit is called, and the basic structure processing unit returns a similarity of 1. After final calculation, the similarity (A4.1, B5.1) = 1, the similarity (A4.2, B5.2) = 1, the similarity (A4.3, B5.3) = 1, the similarity between (A4.1, A4.2, A4.3) and B5.4 is 0, and the similarity between A4 and B5 is 0.4 / 4×3 = 0.3. Therefore, the similarity (A5, B5) = 0.3 + 0.3 + 0.3 = 0.9.
[0126] Specifically, as shown in Table 5, it is a similarity score table between the local interface data and the latest interface data in Table 4.
[0127] Table 5. Similarity score between local interface data and latest interface data.
[0128]
[0129] Based on the principle of maximizing similarity, according to Table 5, the optimal corpus combination is (A1, B2), (A2, B3), (A3, B4), and (A4, B5). The first three matching pairs have a similarity of 1, indicating completely identical element structures. The similarity (A4, B5) = 0.9, indicating a change in the element structure within the local interface data. Furthermore, the degree of change can be determined based on the similarity, and this point can be marked as Modified. B1 has a similarity of 0 with any element in corpus A, and since B1 is an element from the latest interface data, it is marked as Added. Using the similarity calculation formula, the similarity between the two JSON data sets is calculated as (A, B) = 3.9 / 5 = 0.78.
[0130] Additionally, different colors can be used to represent added, deleted, modified, and matched data to visually reflect the differences between two JSON data sets. After obtaining the comparison results, only the changed parts are updated, rather than the entire local interface data.
[0131] Based on the above embodiments, this embodiment provides a local interface data update method, such as... Figure 4 The diagram shows the flowchart of the local interface data update method, including S401-S405:
[0132] S401: Get local interface data and the latest interface data.
[0133] The local interface data is simulated data used to simulate backend interface behavior, and the latest interface data is obtained based on the backend server. The local interface data and the latest interface data include multiple key-value pairs.
[0134] S402: Extract the corpus from the local interface data and the latest interface data respectively.
[0135] The corpus includes key names and value types corresponding to the key names, wherein the value type is the data structure to which the value corresponding to the key name belongs;
[0136] S403: Generate a first corpus chain structure based on the corpus in the local interface data, and generate a second corpus chain structure based on the corpus in the latest interface data.
[0137] Wherein, the first corpus chain structure is used to characterize the hierarchical relationship between each corpus in the local interface data, and the second corpus chain structure is used to characterize the hierarchical relationship between each corpus in the latest interface data;
[0138] S404: Based on the value types included in the corpus, compare each corpus in the first corpus chain structure and the second corpus chain structure to obtain the comparison results.
[0139] S405: Update the local interface data based on the comparison results.
[0140] In one or more embodiments, S404 further includes:
[0141] Based on the value types included in the corpus, identify the corpus processing unit corresponding to each corpus in the first corpus chain structure and the second corpus chain structure;
[0142] The corpora in the first corpus chain structure are combined with the corpora in the second corpus chain structure to obtain multiple corpus combinations;
[0143] The similarity of each combination of corpora is calculated by the corpus processing unit;
[0144] The comparison result is obtained based on the combination of corpora with the highest similarity.
[0145] In one or more embodiments, the corpus processing unit includes at least one of a basic structure processing unit, an array processing unit, and an object processing unit;
[0146] The step of determining the corpus processing unit corresponding to each corpus in the first corpus chain structure and the second corpus chain structure based on the value types included in the corpus includes:
[0147] Obtain the first corpus, the second corpus, and the third corpus from the first corpus chain structure and the second corpus chain structure; wherein, the first corpus includes the corpus with the value type as the basic structure, the second corpus includes the corpus with the value type as an array, and the third corpus includes the corpus with the value type as an object, wherein the basic structure represents the smallest indivisible hierarchical unit of the value, and the object represents the value as a plurality of key-value pairs;
[0148] The corpus processing unit corresponding to the first corpus is confirmed to be the basic structure processing unit, the corpus processing unit corresponding to the second corpus is confirmed to be the array processing unit, and the corpus processing unit corresponding to the third corpus is confirmed to be the object processing unit.
[0149] In one or more embodiments, combining each corpus in the first corpus chain structure with each corpus in the second corpus chain structure to obtain multiple corpus combinations includes:
[0150] Based on the hierarchical relationship in the first corpus chain structure and the second corpus chain structure, each corpus in the first corpus chain structure is combined with each corpus in the second corpus chain structure to obtain multiple initial corpus combinations; wherein, each initial corpus combination includes two corpora.
[0151] Obtain the target corpus combination from the initial corpus combination, and use the target corpus combination as the corpus combination; wherein, the target corpus combination consists of two corpora that have the same value type.
[0152] In one or more embodiments, calculating the similarity of each of the corpus combinations by the corpus processing unit includes:
[0153] If the value type corresponding to the corpus included in the corpus combination is a basic structure, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent; wherein, the basic structure represents the smallest indivisible hierarchical unit of the value.
[0154] If the key names are the same, the similarity of the corpus combination is equal to the maximum value; if the key names are different, the similarity of the corpus combination is equal to 0.
[0155] In one or more embodiments, calculating the similarity of each of the corpus combinations by the corpus processing unit includes:
[0156] If the value type corresponding to the corpus included in the corpus combination is an object, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent; wherein, the object represents that the value includes multiple key-value pairs;
[0157] If the key names are inconsistent, the similarity of the corpus combinations is equal to 0;
[0158] If the key names are consistent, obtain the sub-corpora included in each of the corpora in the corpus combination, group each of the sub-corpora into multiple sub-corpus combinations, and calculate the similarity of each of the sub-corpus combinations through the corpus processing unit;
[0159] The similarity of the corpus combinations is calculated based on the similarity of the sub-corpus combinations.
[0160] In one or more embodiments, calculating the similarity of each of the corpus combinations by the corpus processing unit includes:
[0161] If the value type corresponding to the corpus included in the corpus combination is an array, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent;
[0162] If the key names are inconsistent, the similarity of the corpus combination is 0; if the key names are consistent, virtual key names are generated for the internal elements of the first array and the second array; wherein, the first array is the value corresponding to the corpus belonging to the first corpus chain structure in the corpus combination, and the second array is the value corresponding to the corpus belonging to the second corpus chain structure in the corpus combination.
[0163] Associating the data structure corresponding to each of the internal elements with the virtual key name generates multiple virtual corpora;
[0164] The virtual corpus in the first array is combined with the virtual corpus in the second array to obtain multiple sub-corpus combinations, and the similarity of each sub-corpus combination is calculated by the corpus processing unit.
[0165] The similarity of the corpus combinations is calculated based on the similarity of the sub-corpus combinations.
[0166] In one or more embodiments, calculating the similarity of the corpus combinations based on the similarity of the sub-corpus combinations includes:
[0167] If the key names are the same, the corpus combination is assigned a score of a; if the corpus combinations include corpora with the same value type, the corpus combination is assigned a score of b.
[0168] The corpus combination is assigned a score of c based on the maximum similarity of the sub-corpus combination;
[0169] Adding a, b, and c together yields the similarity of the corpus combination.
[0170] In one or more embodiments, calculating the similarity of each of the sub-corpus combinations by the corpus processing unit includes:
[0171] Based on the value type corresponding to each of the sub-corpus combinations, determine the corpus processing unit corresponding to each of the sub-corpus combinations;
[0172] The corpus processing unit calculates the similarity of each sub-corpus combination by comparing the key names and value types in each sub-corpus combination.
[0173] In one or more embodiments, updating the local interface data based on the comparison result includes:
[0174] Based on the comparison results, the data to be updated in the local interface data is confirmed; wherein, the data to be updated includes at least one of newly added data, deleted data, and modified data;
[0175] The local interface data is updated based on the data to be updated.
[0176] In one or more embodiments, it further includes:
[0177] According to the pre-agreed interface format between the front-end and the back-end, the local interface data is generated, and a local interface is created based on the local interface data; wherein, the local interface is used to simulate the behavior of the back-end interface, the back-end interface is used to call the back-end server, and the local interface is used to call the front-end local server;
[0178] During the development of the front-end, if a data request is received from the front-end, the current development mode is identified; wherein, the current development mode is used to determine the server that the front-end needs to call.
[0179] If the current development mode is local development mode, send the data request to the local interface to invoke the front-end local server;
[0180] If the current development mode is proxy development mode, send the data request to the backend interface to invoke the backend server.
[0181] According to another aspect of the embodiments of this disclosure, a local interface data update apparatus is provided, such as... Figure 5 As shown, the device includes:
[0182] The acquisition module 501 is used to acquire local interface data and the latest interface data; wherein, the local interface data is simulated data used to simulate the behavior of the backend interface, and the latest interface data is obtained based on the backend server, and the local interface data and the latest interface data include multiple key-value pairs;
[0183] The corpus extraction module 502 is used to extract corpora from the local interface data and the latest interface data respectively; wherein, the corpus includes key names and value types corresponding to the key names, and the value type is the data structure to which the value corresponding to the key name belongs;
[0184] The corpus chain structure generation module 503 is used to generate a first corpus chain structure based on the corpus in the local interface data, and to generate a second corpus chain structure based on the corpus in the latest interface data; wherein, the first corpus chain structure is used to characterize the hierarchical relationship between the corpora in the local interface data, and the second corpus chain structure is used to characterize the hierarchical relationship between the corpora in the latest interface data.
[0185] The comparison module 504 is used to compare each of the corpora in the first corpus chain structure and the second corpus chain structure according to the value types included in the corpus, and obtain the comparison result;
[0186] The update module 505 is used to update the local interface data based on the comparison results.
[0187] In one or more embodiments, the comparison module 504 is used to:
[0188] Based on the value types included in the corpus, identify the corpus processing unit corresponding to each corpus in the first corpus chain structure and the second corpus chain structure;
[0189] The corpora in the first corpus chain structure are combined with the corpora in the second corpus chain structure to obtain multiple corpus combinations;
[0190] The similarity of each combination of corpora is calculated by the corpus processing unit;
[0191] The comparison result is obtained based on the combination of corpora with the highest similarity.
[0192] In one or more embodiments, the comparison module 504 is further configured to:
[0193] Obtain the first corpus, the second corpus, and the third corpus from the first corpus chain structure and the second corpus chain structure; wherein, the first corpus includes the corpus with the value type as the basic structure, the second corpus includes the corpus with the value type as an array, and the third corpus includes the corpus with the value type as an object, wherein the basic structure represents the smallest indivisible hierarchical unit of the value, and the object represents the value as a plurality of key-value pairs;
[0194] The corpus processing unit corresponding to the first corpus is confirmed to be the basic structure processing unit, the corpus processing unit corresponding to the second corpus is confirmed to be the array processing unit, and the corpus processing unit corresponding to the third corpus is confirmed to be the object processing unit.
[0195] In one or more embodiments, the comparison module 504 is further configured to:
[0196] Based on the hierarchical relationship in the first corpus chain structure and the second corpus chain structure, each corpus in the first corpus chain structure is combined with each corpus in the second corpus chain structure to obtain multiple initial corpus combinations; wherein, each initial corpus combination includes two corpora.
[0197] Obtain the target corpus combination from the initial corpus combination, and use the target corpus combination as the corpus combination; wherein, the target corpus combination consists of two corpora that have the same value type.
[0198] In one or more embodiments, the comparison module 504 is further configured to:
[0199] If the value type corresponding to the corpus included in the corpus combination is a basic structure, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent; wherein, the basic structure represents the smallest indivisible hierarchical unit of the value.
[0200] If the key names are the same, the similarity of the corpus combination is equal to the maximum value; if the key names are different, the similarity of the corpus combination is equal to 0.
[0201] In one or more embodiments, the comparison module 504 is further configured to:
[0202] If the value type corresponding to the corpus included in the corpus combination is an object, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent; wherein, the object represents that the value includes multiple key-value pairs;
[0203] If the key names are inconsistent, the similarity of the corpus combinations is equal to 0;
[0204] If the key names are consistent, obtain the sub-corpora included in each of the corpora in the corpus combination, group each of the sub-corpora into multiple sub-corpus combinations, and calculate the similarity of each of the sub-corpus combinations through the corpus processing unit;
[0205] The similarity of the corpus combinations is calculated based on the similarity of the sub-corpus combinations.
[0206] In one or more embodiments, the comparison module 504 is further configured to:
[0207] If the value type corresponding to the corpus included in the corpus combination is an array, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent;
[0208] If the key names are inconsistent, the similarity of the corpus combination is 0; if the key names are consistent, virtual key names are generated for the internal elements of the first array and the second array; wherein, the first array is the value corresponding to the corpus belonging to the first corpus chain structure in the corpus combination, and the second array is the value corresponding to the corpus belonging to the second corpus chain structure in the corpus combination.
[0209] Associating the data structure corresponding to each of the internal elements with the virtual key name generates multiple virtual corpora;
[0210] The virtual corpus in the first array is combined with the virtual corpus in the second array to obtain multiple sub-corpus combinations, and the similarity of each sub-corpus combination is calculated by the corpus processing unit.
[0211] The similarity of the corpus combinations is calculated based on the similarity of the sub-corpus combinations.
[0212] In one or more embodiments, the comparison module 504 is further configured to:
[0213] If the key names are the same, the corpus combination is assigned a score of a; if the corpus combinations include corpora with the same value type, the corpus combination is assigned a score of b.
[0214] The corpus combination is assigned a score of c based on the maximum similarity of the sub-corpus combination;
[0215] Adding a, b, and c together yields the similarity of the corpus combination.
[0216] In one or more embodiments, the comparison module 504 is further configured to:
[0217] Based on the value type corresponding to each of the sub-corpus combinations, determine the corpus processing unit corresponding to each of the sub-corpus combinations;
[0218] The corpus processing unit calculates the similarity of each sub-corpus combination by comparing the key names and value types in each sub-corpus combination.
[0219] In one or more embodiments, the update module 505 is used to:
[0220] Based on the comparison results, the data to be updated in the local interface data is confirmed; wherein, the data to be updated includes at least one of newly added data, deleted data, and modified data;
[0221] The local interface data is updated based on the data to be updated.
[0222] The local interface data update device is further configured to: generate the local interface data according to the interface format pre-agreed between the front end and the back end, and create a local interface based on the local interface data; wherein the local interface is used to simulate the behavior of the back end interface, the back end interface is used to call the back end server, and the local interface is used to call the front end local server.
[0223] During the development of the front-end, if a data request is received from the front-end, the current development mode is identified; wherein, the current development mode is used to determine the server that the front-end needs to call.
[0224] If the current development mode is local development mode, send the data request to the local interface to invoke the front-end local server;
[0225] If the current development mode is proxy development mode, send the data request to the backend interface to invoke the backend server.
[0226] The local interface data update device and the local interface data update method provided in this disclosure are based on the same inventive concept and have the same beneficial effects as the methods they adopt, operate or implement.
[0227] This disclosure also provides a computer device for performing the local interface data update method described above. Please refer to... Figure 6 It illustrates a schematic diagram of a computer device provided by some embodiments of this disclosure. For example... Figure 6As shown, the computer device 6 includes: a processor 600, a memory 601, a bus 602, and a communication interface 603. The processor 600, the communication interface 603, and the memory 601 are connected via the bus 602. The memory 601 stores a computer program that can run on the processor 600. When the processor 600 runs the computer program, it executes the local interface data update method provided in any of the foregoing embodiments of this disclosure.
[0228] The memory 601 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between the device network element and at least one other network element is achieved through at least one communication interface 603 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc.
[0229] Bus 602 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory 601 is used to store programs. After receiving an execution instruction, the processor 600 executes the program. The local interface data update method disclosed in any of the foregoing embodiments of this disclosure can be applied to the processor 600, or implemented by the processor 600.
[0230] The processor 600 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 600 or by instructions in software form. The processor 600 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPTA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this disclosure can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 601. Processor 600 reads the information in memory 601 and, in conjunction with its hardware, completes the steps of the above method.
[0231] The computer device and the local interface data update method provided in this disclosure are based on the same inventive concept and have the same beneficial effects as the methods they adopt, operate or implement.
[0232] This disclosure also provides a computer-readable storage medium corresponding to the local interface data update method provided in the foregoing embodiments. The computer-readable storage medium is an optical disc, on which a computer program (i.e., a computer program product) is stored. When the computer program is run by a processor, it executes the local interface data update method provided in any of the foregoing embodiments.
[0233] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical and magnetic storage media, which will not be elaborated here.
[0234] The computer-readable storage medium provided in the above embodiments of this disclosure and the local interface data update method provided in the embodiments of this disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.
[0235] This disclosure also provides a computer program product; please refer to [reference needed]. Figure 7 The computer program product 700 carries program code, namely computer program 701. The instructions included in the computer program 701 can be used to execute the steps of the local interface data update method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0236] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0237] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0238] The block diagrams of devices, apparatuses, devices, and systems disclosed herein are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.
[0239] Additionally, as used herein, the "or" used in a list of items beginning with "at least one" indicates a separate list, such that a list of, for example, "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not imply that the described example is preferred or better than other examples.
[0240] It should also be noted that in the systems and methods of this disclosure, the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered as equivalent solutions to this disclosure.
[0241] Various changes, substitutions, and modifications can be made to the technology described herein without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of this disclosure is not limited to the specific aspects of the processes, machines, manufactures, events, means, methods, and actions described above. Currently existing or later-developed processes, machines, manufactures, events, means, methods, or actions that perform substantially the same function or achieve substantially the same result as the corresponding aspects described herein can be utilized. Therefore, the appended claims include such processes, machines, manufactures, events, means, methods, or actions within their scope.
[0242] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.
[0243] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations therein.
Claims
1. A method for updating local interface data, characterized in that, include: Obtain local interface data and the latest interface data; wherein, the local interface data is simulated data used to simulate backend interface behavior, and the latest interface data is obtained based on the backend server, and the local interface data and the latest interface data include multiple key-value pairs; Extract the corpus from the local interface data and the latest interface data respectively; wherein, the corpus includes key names and the value types corresponding to the key names, and the value types are the data structures to which the values corresponding to the key names belong; Based on the corpus in the local interface data, a first corpus chain structure is generated, and based on the corpus in the latest interface data, a second corpus chain structure is generated; wherein, the first corpus chain structure is used to characterize the hierarchical relationship between the corpora in the local interface data, and the second corpus chain structure is used to characterize the hierarchical relationship between the corpora in the latest interface data. Based on the value types included in the corpus, each corpus in the first corpus chain structure and the second corpus chain structure is compared to obtain the comparison result; Based on the comparison results, the local interface data is updated.
2. The local interface data update method as described in claim 1, characterized in that, The step of comparing each corpus in the first corpus chain structure and the second corpus chain structure according to the value types included in the corpus to obtain the comparison result includes: Based on the value types included in the corpus, identify the corpus processing unit corresponding to each corpus in the first corpus chain structure and the second corpus chain structure; The corpora in the first corpus chain structure are combined with the corpora in the second corpus chain structure to obtain multiple corpus combinations; The similarity of each combination of corpora is calculated by the corpus processing unit; The comparison result is obtained based on the combination of corpora with the highest similarity.
3. The local interface data update method as described in claim 2, characterized in that, The corpus processing unit includes at least one of a basic structure processing unit, an array processing unit, and an object processing unit; The step of determining the corpus processing unit corresponding to each corpus in the first corpus chain structure and the second corpus chain structure based on the value types included in the corpus includes: Obtain the first corpus, the second corpus, and the third corpus from the first corpus chain structure and the second corpus chain structure; wherein, the first corpus includes the corpus with the value type as the basic structure, the second corpus includes the corpus with the value type as an array, and the third corpus includes the corpus with the value type as an object, wherein the basic structure represents the smallest indivisible hierarchical unit of the value, and the object represents the value as a plurality of key-value pairs; The corpus processing unit corresponding to the first corpus is confirmed to be the basic structure processing unit, the corpus processing unit corresponding to the second corpus is confirmed to be the array processing unit, and the corpus processing unit corresponding to the third corpus is confirmed to be the object processing unit.
4. The local interface data update method as described in claim 2, characterized in that, The step of combining each corpus in the first corpus chain structure with each corpus in the second corpus chain structure to obtain multiple corpus combinations includes: Based on the hierarchical relationship in the first corpus chain structure and the second corpus chain structure, each corpus in the first corpus chain structure is combined with each corpus in the second corpus chain structure to obtain multiple initial corpus combinations; wherein, each initial corpus combination includes two corpora. Obtain the target corpus combination from the initial corpus combination, and use the target corpus combination as the corpus combination; wherein, the target corpus combination consists of two corpora that have the same value type.
5. The local interface data update method as described in claim 2, characterized in that, The step of calculating the similarity of each combination of corpora through the corpus processing unit includes: If the value type corresponding to the corpus included in the corpus combination is a basic structure, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent; wherein, the basic structure represents the smallest indivisible hierarchical unit of the value. If the key names are the same, the similarity of the corpus combination is equal to the maximum value; if the key names are different, the similarity of the corpus combination is equal to 0.
6. The local interface data update method as described in claim 2, characterized in that, The step of calculating the similarity of each combination of corpora through the corpus processing unit includes: If the value type corresponding to the corpus included in the corpus combination is an object, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent; wherein, the object represents that the value includes multiple key-value pairs; If the key names are inconsistent, the similarity of the corpus combinations is equal to 0; If the key names are consistent, obtain the sub-corpora included in each of the corpora in the corpus combination, group each of the sub-corpora into multiple sub-corpus combinations, and calculate the similarity of each of the sub-corpus combinations through the corpus processing unit; The similarity of the corpus combinations is calculated based on the similarity of the sub-corpus combinations.
7. The local interface data update method as described in claim 2, characterized in that, The step of calculating the similarity of each combination of corpora through the corpus processing unit includes: If the value type corresponding to the corpus included in the corpus combination is an array, the corpus processing unit identifies whether the key names of the corpus included in the corpus combination are consistent; If the key names are inconsistent, the similarity of the corpus combination is 0; if the key names are consistent, virtual key names are generated for the internal elements of the first array and the second array; wherein, the first array is the value corresponding to the corpus belonging to the first corpus chain structure in the corpus combination, and the second array is the value corresponding to the corpus belonging to the second corpus chain structure in the corpus combination. Associating the data structure corresponding to each of the internal elements with the virtual key name generates multiple virtual corpora; The virtual corpus in the first array is combined with the virtual corpus in the second array to obtain multiple sub-corpus combinations, and the similarity of each sub-corpus combination is calculated by the corpus processing unit. The similarity of the corpus combinations is calculated based on the similarity of the sub-corpus combinations.
8. The local interface data update method as described in claim 6 or 7, characterized in that, The calculation of the similarity of the corpus combinations based on the similarity of the sub-corpus combinations includes: If the key names are the same, the corpus combination is assigned a score of a; if the corpus combinations include corpora with the same value type, the corpus combination is assigned a score of b. The corpus combination is assigned a score of c based on the maximum similarity of the sub-corpus combination; Adding a, b, and c together yields the similarity of the corpus combination.
9. The local interface data update method as described in claim 6 or 7, characterized in that, The step of calculating the similarity of each of the sub-corpus combinations through the corpus processing unit includes: Based on the value type corresponding to each of the sub-corpus combinations, determine the corpus processing unit corresponding to each of the sub-corpus combinations; The corpus processing unit calculates the similarity of each sub-corpus combination by comparing the key names and value types in each sub-corpus combination.
10. The local interface data update method as described in claim 1, characterized in that, The step of updating the local interface data based on the comparison result includes: Based on the comparison results, the data to be updated in the local interface data is confirmed; wherein, the data to be updated includes at least one of newly added data, deleted data, and modified data; The local interface data is updated based on the data to be updated.
11. The local interface data update method as described in claim 1, characterized in that, Also includes: According to the pre-agreed interface format between the front-end and the back-end, the local interface data is generated, and a local interface is created based on the local interface data; wherein, the local interface is used to simulate the behavior of the back-end interface, the back-end interface is used to call the back-end server, and the local interface is used to call the front-end local server; During the development of the front-end, if a data request is received from the front-end, the current development mode is identified; wherein, the current development mode is used to determine the server that the front-end needs to call. If the current development mode is local development mode, send the data request to the local interface to invoke the front-end local server; If the current development mode is proxy development mode, send the data request to the backend interface to invoke the backend server.
12. A local interface data update device, characterized in that, include: The data acquisition module is used to acquire local interface data and the latest interface data; wherein, the local interface data is simulated data used to simulate the behavior of the backend interface, and the latest interface data is obtained based on the backend server, and the local interface data and the latest interface data include multiple key-value pairs; The corpus extraction module is used to extract corpora from the local interface data and the latest interface data respectively; wherein, the corpus includes key names and value types corresponding to the key names, and the value type is the data structure to which the value corresponding to the key name belongs; A corpus chain structure generation module is used to generate a first corpus chain structure based on the corpus in the local interface data, and to generate a second corpus chain structure based on the corpus in the latest interface data; wherein, the first corpus chain structure is used to characterize the hierarchical relationship between the corpora in the local interface data, and the second corpus chain structure is used to characterize the hierarchical relationship between the corpora in the latest interface data. The comparison module is used to compare each of the corpora in the first corpus chain structure and the second corpus chain structure according to the value types included in the corpus, and obtain the comparison result; An update module is used to update the local interface data based on the comparison results.
13. A computer embedded device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the method according to any one of claims 1 to 11.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 11.
15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 11.
Citation Information
Patent Citations
Structured text comparison method and device
CN111506608A
Message comparison method and system and computer readable storage medium
CN119743538A