JS object representation data processing method and device, equipment and storage medium

By spanning the tree structure and generating a unique fingerprint for the JSON data node, the JSON data comparison problem is solved, and the comparability of JSON data structure and efficient identification of data changes is achieved.

CN119397058APending Publication Date: 2025-02-07FAW VOLKSWAGEN AUTOMOTIVE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410004323.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-02
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

It is difficult to effectively compare different versions of JSON format data in the prior art, especially in the data type nested structure, due to the lack of fingerprint identification, it is impossible to accurately compare node data.

Method used

By spanning the tree structure and generating a unique fingerprint for each node, the node fingerprints in the tree structure are compared, the node state is identified, and the data change field is updated if necessary.

Benefits of technology

Comparability of JSON data structure is achieved, and the changes in the node state identification data between different versions are facilitated, which is conducive to subsequent queries and data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119397058A_ABST
    Figure CN119397058A_ABST
Patent Text Reader

Abstract

The invention provides a JS object representation data processing method and device, equipment and a storage medium. The method comprises the steps that first JS object representation data and second JS object representation data are converted into a tree structure, and fingerprints of nodes are generated according to values of fields in the nodes; comparing child nodes under root nodes with the same fingerprints in the first tree structure and the second tree structure, respectively distributing different state values for deleted nodes, newly added nodes, nodes with unchanged data and nodes with changed data of the second tree structure relative to the first tree structure, adding the state values into fields of the nodes, and adding the changed nodes and node data of the second tree structure to the first tree structure, converting the first tree structure into a comparison result JS object representation file, and storing the comparison result JS object representation file in a database. The technical problem that JSON data are difficult to compare is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention generally relate to the field of data processing technology, and more specifically, to a JS object representation data processing method, apparatus, device and storage medium. Background Art

[0002] In the field of data processing, especially in the processing of vehicle body data, it is necessary to parse files in the Extensible Markup Language (XML) format and convert them into JavaScript Object Notation (JSON) format data, and the contents of different versions of JSON format data need to be compared.

[0003] JSON format data includes object type JSONObject and array type JSONArray. JSONObject and JSONArray can form mutually nested structures. In the formed nested structure, due to the data type, some types of node data cannot be compared between them because they do not have fingerprints or other identifiers. Summary of the invention

[0004] In order to solve the above-mentioned problems in the prior art, in the first aspect, an embodiment of the present invention provides a JS object representation data processing method, the method comprising the steps of: S101, obtaining first JS object representation data and second JS object representation data, wherein the first JS object representation data and the second JS object representation data each include mutually nested object type and array type data; S102, generating a first tree structure and a second tree structure respectively according to the data type nesting structure in the first JS object representation data and the second JS object representation data; S103, for each node in the first tree structure and the second tree structure, generating a first tree structure and a second tree structure according to the value of a field in the predefined node to generate a fingerprint of the node; S104, for the current root node with the same fingerprint in the first tree structure and the second tree structure, respectively obtain a first child node list under the current root node in the first tree structure and a second child node list under the current root node in the second tree structure, wherein the first child node list includes one or more first child nodes, and the second child node list includes one or more second child nodes; S105, compare the fingerprint of the first child node with the fingerprint of the second child node; S106, if the fingerprint of the current first child node in the first child node list is different from the fingerprints of all the second child nodes in the second child node list, compare the fingerprint of the current first child node with the fingerprint of all the second child nodes in the second child node list; The node state is set to the first state value, and the node state is added to the node data of the current first child node; S107, when the fingerprint of the current second child node in the second child node list is different from the fingerprints of all the first child nodes in the first child node list, the node state of the current second child node is set to the second state value, the node state is added to the node data of the current second child node, and the node data of the current second child node is added to the corresponding position in the first child node list; S108, when the fingerprint of the current first child node in the first child node list is the same as the fingerprint of the current second child node in the second child node list, determine the current first child node with the same fingerprint. Whether the node data in the child node and the current second child node are consistent; S109, if the node data are consistent, set the node state of the current first child node in the first child node list to the third state value, and add the node state to the node data of the current first child node; S110, if the node data are inconsistent, set the node state of the current first child node in the first child node list to the fourth state value, and extract the node data of the current second child node and add it to the data change field of the current first child node; S111, use the current first child node with the node state of the fourth state value and the corresponding current second child node as the current root nodes of the first tree structure and the second tree structure respectively;S112, determine whether the first child node list under the current root node of the first tree structure and the second child node list under the current root node of the second tree structure are both empty, if yes, go to step S113, if not, go to step S104; S113, convert the first tree structure into a comparison result JS object representation file and store it in the database.;

[0005] In some embodiments, the method further includes: receiving a query instruction input by a user, the query instruction including one or more of the following: a specified file name, a specified node fingerprint, a specified node status value, a specified field, a specified field keyword, and a specified tree structure range; obtaining a query result corresponding to the query instruction in the database; and outputting the query result to the user.

[0006] In some embodiments, step S102 includes: for the first JS object representation data: taking the root node of the first JS object representation data as the current node; obtaining the current local data in the node data of the current node, wherein the current local data does not contain array type data; generating a node of the first tree structure for the current local data; when the value of the current local data is array type data, taking the child node in the array type data as the new current node, and executing the steps of obtaining the current local data and generating a node of the first tree structure for the new current node; when the value of the local data of each node of the generated first tree structure is not array type data, generating a complete first tree structure. For the second JS object representing data: take the root node of the second JS object representing data as the current node; obtain the current local data in the node data of the current node, wherein the current local data does not contain array type data; generate a node of the second tree structure for the current local data; when the value of the current local data is array type data, take the child node in the array type data as the new current node, and execute the steps of obtaining the current local data and generating a node of the second tree structure for the new current node; when the value of the local data of each node of the generated second tree structure is not array type data, generate a complete second tree structure.

[0007] In some implementations, step S103 includes: according to a predefined rule, concatenating the values ​​of the fields in the predefined node into a string as the fingerprint of the node.

[0008] In some implementations, step S103 includes: calculating the fingerprint of the node according to the value of a predefined field in the node based on a predefined fingerprint calculation formula.

[0009] In some embodiments, step S105 includes: traversing the first child node list, and comparing the fingerprint of each first child node in the first child node list with the fingerprint of the second child node in the second child node list in turn; traversing the second child node list, and comparing the fingerprint of each second child node in the second child node list with the fingerprint of the first child node in the first child node list in turn.

[0010] In a second aspect, an embodiment of the present invention proposes a JS object representation data processing device, the device comprising: a JS object representation data acquisition module, configured to acquire first JS object representation data and second JS object representation data, wherein the first JS object representation data and the second JS object representation data each include mutually nested object types and array type data; a tree structure generation module, configured to generate a first tree structure and a second tree structure according to the data type nesting structure in the first JS object representation data and the second JS object representation data, respectively; a fingerprint generation module, configured to generate a fingerprint for each node in the first tree structure and the second tree structure according to a predefined node The fingerprint of the node is generated by the value of the field in the first tree structure; a child node list acquisition module is configured to obtain, for the current root node with the same fingerprint in the first tree structure and the second tree structure, a first child node list under the current root node in the first tree structure and a second child node list under the current root node in the second tree structure, respectively, wherein the first child node list includes one or more first child nodes, and the second child node list includes one or more second child nodes; a fingerprint comparison module is configured to compare the fingerprint of the first child node with the fingerprint of the second child node; a first state value setting module is configured to compare the fingerprint of the current first child node in the first child node list with the fingerprint of the second child node in the second child node list; when the fingerprints of all the second child nodes in the first child node list are different, the node state of the current first child node is set to the first state value, and the node state is added to the node data of the current first child node; a second state value setting module is configured to, when the fingerprint of the current second child node in the second child node list is different from the fingerprints of all the first child nodes in the first child node list, set the node state of the current second child node to the second state value, add the node state to the node data of the current second child node, and add the node data of the current second child node to the corresponding position in the first child node list; a data consistency judgment module is configured to, when the fingerprint of the current first child node in the first child node list is different from the fingerprints of all the first child nodes in the first child node list, set the node state of the current second child node to the second state value, add the node state to the node data of the current second child node, and add the node data of the current second child node to the corresponding position in the first child node list; When the fingerprint is the same as the fingerprint of the current second child node in the second child node list, determine whether the node data in the current first child node and the current second child node with the same fingerprint are consistent; a third state value setting module is configured to set the node state of the current first child node in the first child node list to the third state value when the node data are consistent, and add the node state to the node data of the current first child node; a fourth state value setting module is configured to set the node state of the current first child node in the first child node list to the fourth state value when the node data are inconsistent, and extract the node data of the current second child node and add it to the data change field of the current first child node;The current root node update module is configured to use the current first child node and the corresponding current second child node whose node status is the fourth status value as the current root nodes of the first tree structure and the second tree structure respectively; the child node list judgment module is configured to judge whether the first child node list under the current root node of the first tree structure and the second child node list under the current root node of the second tree structure are both empty, if yes, then turn to the comparison result generation module, if not, then turn to the child node list acquisition module; the comparison result generation module is configured to convert the first tree structure into a comparison result JS object representation file and store it in a database. ;

[0011] In some embodiments, the device also includes a query module configured to: receive a query instruction input by a user, the query instruction including one or more of the following: a specified file name, a specified node fingerprint, a specified node status value, a specified field, a specified field keyword, and a specified tree structure range; obtain a query result corresponding to the query instruction in the database; and output the query result to the user.

[0012] In a third aspect, an embodiment of the present invention proposes a JS object representation data processing device, the device comprising a memory and a processor, the memory storing a computer program, and implementing the JS object representation data processing method described in any of the above embodiments when the computer program is executed by the processor.

[0013] In a fourth aspect, an embodiment of the present invention provides a storage medium storing computer-readable instructions, which, when executed by a processor, executes the JS object representation data processing method described in any of the above embodiments.

[0014] The JS object representation data processing method, device, equipment and storage medium proposed in the embodiments of the present invention solve the technical problem that JSON data is difficult to compare at present. For the case where each child node value in the JSON data to be compared is a JSONArray, a unique fingerprint is assigned to each node in the JSONArray according to specific rules, so that the JSON data structure becomes a comparable structure. Then, by assigning a status value to the node after comparison, the change of the node between the two compared data can be simply and efficiently identified, which is conducive to subsequent query and further data processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The above and other objects, features and advantages of the embodiments of the present invention will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, in which:

[0016] Figure 1A flowchart of a JS object representation data processing method according to an embodiment of the present invention is shown;

[0017] Figure 2 A schematic flowchart of a JS object representation data processing method according to an embodiment of the present invention is shown;

[0018] Figure 3 A flowchart showing an example of a tree structure generation process of a JS object representation data processing method according to an embodiment of the present invention;

[0019] Figure 4 A flowchart showing an example of a tree content comparison process of a JS object representation data processing method according to an embodiment of the present invention;

[0020] Figure 5 An example program architecture diagram for executing a JS object representation data processing method according to an embodiment of the present invention is shown;

[0021] Figure 6 A block diagram showing a JS object representation data processing device according to an embodiment of the present invention.

[0022] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts. DETAILED DESCRIPTION

[0023] The principle and spirit of the present invention will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present invention, and are not intended to limit the scope of the present invention in any way.

[0024] In one aspect, an embodiment of the present invention provides a method for processing JavaScript Object Notation (JSON) data. Figure 1 , which shows a flow chart of a JS object representation data processing method 100 according to an embodiment of the present invention. The method 100 includes steps S101-S113.

[0025] For ease of understanding, combined Figure 2 The general framework of the JS object representation data processing method proposed in the embodiment of the present invention is described. Figure 2 A schematic flowchart of the framework of a JS object representation data processing method according to an embodiment of the present invention is shown.

[0026] like Figure 2As shown, the JS object representation data processing method proposed in the embodiment of the present invention generally includes the following processes: taking two JSON data to be compared as input parameters; converting the JSON data into a tree according to the rules, and generating a fingerprint for each node of the tree according to a specific formula; comparing the contents of the tree, and generating a comparison result in JSON format; and storing the comparison result in a database.

[0027] In the process of converting JSON data into a tree, the JSON data can be iterated to calculate unique fingerprint data for each node according to rules, and the JSON data can be converted into a tree data structure according to specific regulations.

[0028] In the process of comparing the contents of the trees, the two trees that need to be compared can be iterated and traversed to determine whether the node is a newly added / deleted node based on the fingerprint, etc. Different nodes can be assigned different states, and the comparison result JSON data can be generated and stored in the database.

[0029] For the purpose of illustration and ease of understanding, two data types of JSON data, JSONObject and JSONArray, in the embodiments of the present invention are exemplarily described below.

[0030] JSONObject is essentially a hash table, including key and value pairs. The key type is a string, and the value is any data type. The data type of the value includes JSONObject and JSONArray. The following is a simple example of a form of JSONObject type data:

[0031]

[0032] Among them, a, b, c are keys, and 1, 2, 3 are the values ​​of each key respectively.

[0033] The following is a simple example of another form of JSONObject type data:

[0034]

[0035] Among them, "array2" is the key, its value is an array, and the array elements include "d", "e", and "f". "array1" is the key, its value is an array, and the array elements include "a", "b", and "c".

[0036] JSONArray is essentially a list, and its elements are of any data type, which can include JSONObject and JSONArray.

[0037] The following is a simple example of one form of JSONArray type data:

[0038]

[0039] The array elements include "a", "b", and "c".

[0040] The following is a simple example of another form of JSONArray type data:

[0041]

[0042] The elements in the array are JSON objects, such as key-value pairs such as "a":1.

[0043] In the application scenario of the present invention, the premise for JSON / tree data to be comparable is that a parent node has multiple child nodes, and each child node must have a unique fingerprint. The following is a schematic and simple example of a comparable structure:

[0044]

[0045]

[0046] and

[0047]

[0048] In this example, the keys in the JSONArray are themselves strings with unique fingerprints, so the two JSON data are comparable.

[0049] Here is a schematically simple example of incomparable structures:

[0050]

[0051]

[0052] and

[0053]

[0054] In this example, the value of JSONArray is still JSONArray, and the structure and data content are unknown. Since the fingerprint information to distinguish the data nodes cannot be found, the two JSON data cannot be compared.

[0055] The following combination Figure 1 The steps of the method are described in detail.

[0056] In step S101, a first JS object representation data and a second JS object representation data are obtained, wherein the first JS object representation data and the second JS object representation data each include mutually nested object type and array type data. The first JS object representation data and the second JS object representation data are two data to be compared, which may be different data versions of body data representing the same vehicle model, an old version and a new version, and a comparison needs to be made between the old version and the new version.

[0057] In step S102, a first tree structure and a second tree structure are generated according to the data type nesting structure in the first JS object representation data and the second JS object representation data. The essence of JSON data is a tree, and JSON data and tree structures can be converted to each other.

[0058] In step S103, for each node in the first tree structure and the second tree structure, a fingerprint of the node is generated according to the value of a predefined field in the node.

[0059] As an implementation of the present invention, step S103 may include: according to a predefined rule, concatenating the values ​​of the fields in the predefined node into a string as the fingerprint of the node.

[0060] As another implementation of the present invention, step S103 may include: calculating the fingerprint of the node according to the value of a predefined field in the node based on a predefined fingerprint calculation formula.

[0061] It should be noted that step S102 and step S103 can be executed sequentially, synchronously or interspersed. For example, after all nodes of the tree structure are generated, that is, after a complete tree is generated, the fingerprint of each node is generated. Alternatively, the fingerprint of each node can be generated immediately when each node of the tree structure is generated. It can be flexibly configured in practical applications.

[0062] In step S104, for the current root node with the same fingerprint in the first tree structure and the second tree structure, a first child node list under the current root node in the first tree structure and a second child node list under the current root node in the second tree structure are obtained respectively, the first child node list includes one or more first child nodes, and the second child node list includes one or more second child nodes.

[0063] In step S105, the fingerprint of the first child node is compared with the fingerprint of the second child node.

[0064] In step S106, when the fingerprint of the current first child node in the first child node list is different from the fingerprints of all the second child nodes in the second child node list, it means that the current first child node has been deleted in the second JSON data, and the node state of the current first child node is set to the first state value (for example, -1) to indicate that the node has been deleted, and the node state is added to the node data of the current first child node.

[0065] In step S107, when the fingerprint of the current second child node in the second child node list is different from the fingerprints of all the first child nodes in the first child node list, it means that the current second child node does not exist in the first JSON data and is newly added in the second JSON data, then the node state of the current second child node is set to the second state value (for example, 1), the node state is added to the node data of the current second child node, and the node data of the current second child node is added to the corresponding position in the first child node list.

[0066] In step S108, when the fingerprint of the current first child node in the first child node list is the same as the fingerprint of the current second child node in the second child node list, it is determined whether the node data in the current first child node and the current second child node having the same fingerprint are consistent.

[0067] In step S109, when the node data is consistent, it means that the data of the node has not changed between the two JSON data, then the node state of the current first child node in the first child node list is set to the third state value (for example, 0), and the node state is added to the node data of the current first child node.

[0068] In step S110, if the node data is inconsistent, it means that the node data has been modified in the second JSON data, then the node state of the current first child node in the first child node list is set to the fourth state value (for example, 2), and the node data of the current second child node is extracted and added to the data change field of the current first child node.

[0069] In step S111, the current first child node whose node state is the fourth state value and the corresponding current second child node are respectively used as the current root nodes of the first tree structure and the second tree structure.

[0070] In step S112, it is determined whether the first child node list under the current root node in the first tree structure and the second child node list under the current root node in the second tree structure are both empty. If yes, go to step S113; if not, go to step S104.

[0071] In step S113, the first tree structure is converted into a comparison result JS object representation file and stored in a database, which may be, for example, a MongoDB database.

[0072] As an embodiment of the present invention, the method may also include a data query process, specifically including: receiving a query instruction input by a user, the query instruction including one or more of the following: a specified file name, a specified node fingerprint, a specified node status value, a specified field, a specified field keyword, a specified tree structure range; obtaining a query result corresponding to the query instruction in the database; and outputting the query result to the user.

[0073] By querying the comparison results, you can query any range of local JSON data containing the comparison results. The front end displays the JSON data comparison results accurate to the field by performing secondary rendering of the single node data itself and the data change field content.

[0074] As an embodiment of the present invention, step S102 may include: for the first JS object representing data, taking the root node of the first JS object representing data as the current node; obtaining the current local data in the node data of the current node, wherein the current local data does not contain array type data; generating a node of the first tree structure for the current local data; when the value of the current local data is array type data, taking the child node in the array type data as the new current node, and executing the steps of obtaining the current local data and generating a node of the first tree structure for the new current node; when the value of the local data of each node of the generated first tree structure is not array type data, generating a complete first tree structure.

[0075] The same operation is performed on the second JS object representing the data, that is, the root node of the second JS object representing the data is taken as the current node; the current local data is obtained from the node data of the current node, wherein the current local data does not contain array type data; a node of the second tree structure is generated for the current local data; when the value of the current local data is array type data, the child node in the array type data is taken as the new current node, and the steps of obtaining the current local data and generating a node of the second tree structure are performed for the new current node; when the value of the local data of each node of the generated second tree structure is not array type data, a complete second tree structure is generated.

[0076] The following combination Figure 3 A specific example is shown to exemplarily illustrate the tree structure generation process of the JS object representation data processing method according to an embodiment of the present invention.

[0077] like Figure 3As shown, two JSON data to be compared are used as input parameters: a new version of JSON and an old version of JSON. First, the root node of the JSON data is used as the current node. The local data of the JSON data is obtained so that the current local data does not contain the JSONArray data structure. The current local data can be, for example, the root node itself, without considering the child nodes. In the case where several child nodes of the root node are JSONArray, the child nodes as arrays are ignored, and the root node is given a fingerprint. Then, the node of the tree is generated for the current local data, and the fingerprint is generated according to the formula. For example, the formula can be string concatenation, and the string is the value of a specific key after removing the JSONArray type element under the node, and the fingerprint is concatenated as the fingerprint. The fingerprint is calculated according to a pre-configured algorithm, and the value of the current local data (including the JSONArray data structure) and the fingerprint are assigned to the node of the tree at the same time. Next, it is determined whether the value type of the current local data is JSONArray, in other words, whether the type of the child node under the current node is JSONarray. If so, the JSONArray of the value of this local data is iterated, and the child nodes in each JSONArray are used as the current node. If not, the root node of the JSON data is used as the root node of the tree and the complete tree is returned.

[0078] The program that converts JSON data into a tree converts JSON data into a tree data structure through the above process, making the JSON data into a comparable structure while retaining the data content. The formula program for generating fingerprints for each node is determined by the actual content of the JSON data, ensuring that the fingerprint generated according to this formula is unique in the JSON data.

[0079] As an embodiment of the present invention, step S105 may include: traversing the first child node list, and comparing the fingerprint of each first child node in the first child node list with the fingerprint of the second child node in the second child node list in turn; traversing the second child node list, and comparing the fingerprint of each second child node in the second child node list with the fingerprint of the first child node in the first child node list in turn.

[0080] The following combination Figure 4 A specific example is shown to exemplarily illustrate the tree content comparison process of the JS object representation data processing method according to an embodiment of the present invention.

[0081] like Figure 4As shown, the tree content comparison process may include: taking the root node root1 (root node 1) of tree 1 and the root node root2 (root node 2) of tree 2 as input parameters; obtaining the child node list children1 of root1 and the child node list children2 of root2; judging whether children1 and children2 are both empty? If not, and not both empty, traverse children1; judging whether the fingerprint of a single child node in children1 is different from the fingerprints of all child nodes in children2? If not, traverse children2 and judge whether the fingerprint of a single child node in children2 is different from the fingerprints of all child nodes in children1? If not, it means that this node originally existed in tree 1; judging whether the data of this node is exactly the same as the data of the node with the same fingerprint in children1? If yes, it means that the data of this single child node has not changed, and the node status is set to 0; if no, it means that the data content of this single child node has changed; this child node is used as the new root node root2, and the node with the same fingerprint as this child node in children1 is used as the new root node root1; the root1 node status position is set to 2, and the root2 node data is extracted and added to the data change field in the root1 node data. The field name can be defined by yourself, such as JSONOld or JSONNew; when the step of judging whether children1 and children2 are both empty is judged as yes, tree 1 is included The tree of all complete comparison results is converted into a JSON file and stored in the database; if the step of judging whether the fingerprint of a single child node in children1 is different from the fingerprints of all child nodes in children2 is judged as yes, it means that this single child node is deleted in tree 2, and the state of this node is set to -1; if the step of judging whether the fingerprint of a single child node in children2 is different from the fingerprints of all child nodes in children1 is judged as yes, it means that this single child node did not exist in tree 1 originally, and it is a newly added node, and the state position of this node is set to 1, and this newly added node is added to the corresponding position in children1.

[0082] The program for comparing the contents of the trees iterates through the two trees 1 and 2 to be compared, identifies the positions of the nodes to be compared in the two trees through node fingerprints, and then compares the contents of the two nodes with the same fingerprint, and adds the changed data to the jsonOld field of the original node. Each node is assigned its own status bit, where 0 means no change; 1 means new addition; -1 means deletion; 2 means update. After completing the comparison of tree 1 and tree 2, tree 1 is the tree containing all the comparison results, and tree 1 is converted into JSON data and stored in a database, such as a MongoDB database.

[0083] refer to Figure 5 , which shows an example program architecture diagram for executing the JS object representation data processing method according to an embodiment of the present invention. The overall architecture includes a presentation layer, a business layer, and a database. The business layer includes a program for converting JSON data into a tree, a program for comparing the contents of the tree, a JSON data storage program, and an optional JSON data query program. All JSON data are stored in the database, including the JSON data to be compared and the comparison result JSON data.

[0084] In view of the difficulty in comparing JSON data, the implementation mode of the present invention targets the case where the value of each child node in the JSON data to be compared is a JSONArray, and assigns a unique fingerprint to each node in the JSONArray according to specific rules, so that the JSON data structure becomes a comparable structure, thereby solving the technical problem that JSON data is difficult to compare.

[0085] On the other hand, an embodiment of the present invention provides a JS object representation data processing device. Figure 6 The block diagram of the JS object representation data processing device according to the embodiment of the present invention is shown. The device includes modules 601-613.

[0086] The JS object representation data acquisition module 601 may be configured to acquire first JS object representation data and second JS object representation data, wherein the first JS object representation data and the second JS object representation data each include mutually nested object type and array type data.

[0087] The tree structure generating module 602 may be configured to generate a first tree structure and a second tree structure respectively according to the data type nesting structure in the first JS object representing the data and the second JS object representing the data.

[0088] The fingerprint generation module 603 may be configured to generate a fingerprint of each node in the first tree structure and the second tree structure according to a value of a predefined field in the node.

[0089] The child node list acquisition module 604 can be configured to obtain, for the current root node having the same fingerprint in the first tree structure and the second tree structure, a first child node list under the current root node in the first tree structure and a second child node list under the current root node in the second tree structure, respectively, wherein the first child node list includes one or more first child nodes, and the second child node list includes one or more second child nodes.

[0090] The fingerprint comparison module 605 may be configured to compare the fingerprint of the first child node with the fingerprint of the second child node.

[0091] The first state value setting module 606 can be configured to set the node state of the current first child node to the first state value and add the node state to the node data of the current first child node when the fingerprint of the current first child node in the first child node list is different from the fingerprints of all the second child nodes in the second child node list.

[0092] The second state value setting module 607 can be configured to set the node state of the current second child node to the second state value, add the node state to the node data of the current second child node, and add the node data of the current second child node to the corresponding position in the first child node list when the fingerprint of the current second child node in the second child node list is different from the fingerprints of all first child nodes in the first child node list.

[0093] The data consistency judgment module 608 can be configured to judge whether the node data in the current first child node and the current second child node with the same fingerprint are consistent when the fingerprint of the current first child node in the first child node list is the same as the fingerprint of the current second child node in the second child node list.

[0094] The third state value setting module 609 may be configured to set the node state of the current first child node in the first child node list to the third state value when the node data is consistent, and add the node state to the node data of the current first child node.

[0095] The fourth state value setting module 610 can be configured to set the node state of the current first child node in the first child node list to the fourth state value when the node data is inconsistent, and extract the node data of the current second child node and add it to the data change field of the current first child node.

[0096] The current root node updating module 611 may be configured to use the current first child node with the node state of the fourth state value and the corresponding current second child node as the current root nodes of the first tree structure and the second tree structure, respectively.

[0097] The child node list judgment module 612 can be configured to judge whether the first child node list under the current root node of the first tree structure and the second child node list under the current root node of the second tree structure are both empty. If so, it goes to the comparison result generation module; if not, it goes to the child node list acquisition module.

[0098] The comparison result generating module 613 may be configured to convert the first tree structure into a comparison result JS object representation file and store it in a database.

[0099] As an embodiment of the present invention, the device may also include a query module, configured to: receive a query instruction input by a user, the query instruction including one or more of the following: a specified file name, a specified node fingerprint, a specified node status value, a specified field, a specified field keyword, a specified tree structure range; obtain a query result corresponding to the query instruction in the database; and output the query result to the user.

[0100] It should be noted that the functions implemented by each module in the JS object representation data processing device proposed in the embodiment of the present invention correspond one-to-one to the various steps of the JS object representation data processing method described above. For its specific implementation methods, examples and beneficial effects, please refer to the above description of the method.

[0101] On another aspect, an embodiment of the present invention proposes a JS object representation data processing device, the device includes a memory and a processor, a computer program is stored in the memory, and when the computer program is executed by the processor, the JS object representation data processing method described in any of the above embodiments is implemented.

[0102] On the other hand, an embodiment of the present invention provides a storage medium storing computer-readable instructions, which, when executed by a processor, executes the JS object representation data processing method described in any of the above embodiments.

[0103] The JS object representation data processing method, device, equipment and storage medium proposed in the embodiments of the present invention solve the technical problem that JSON data is difficult to compare at present. For the case where each child node value in the JSON data to be compared is a JSONArray, a unique fingerprint is assigned to each node in the JSONArray according to specific rules, so that the JSON data structure becomes a comparable structure. Then, by assigning a status value to the node after comparison, the change of the node between the two compared data can be simply and efficiently identified, which is conducive to subsequent query and further data processing.

[0104] The technical solution proposed in the embodiments of the present invention can be widely used in comparison scenarios of JSON data such as vehicle body data.

[0105] For the purpose of illustration, the foregoing description of the embodiments of the present invention has been given, which is not exhaustive nor intended to limit the present invention to the disclosed exact form. It will be appreciated by those skilled in the art that various changes can be made without departing from the scope of the present invention, and that the elements therein can be replaced with equivalents. In addition, without departing from the basic scope of the present invention, many modifications can be made so that specific situations or materials are adapted to the teachings of the present invention. Therefore, the present invention is not intended to be limited to the specific embodiments disclosed as the best mode for realizing the present invention, and the present invention will include all embodiments falling within the scope of the appended claims.

Claims

1. A JS object representation data processing method, characterized in that: The method comprises the steps of: S101, obtaining first JS object representation data and second JS object representation data, wherein the first JS object representation data and the second JS object representation data each include object type and array type data that can be nested with each other; S102, generating a first tree structure and a second tree structure respectively according to the data type nesting structure in the first JS object representation data and the second JS object representation data; S103: for each node in the first tree structure and the second tree structure, generate a fingerprint of the node according to a value of a predefined field in the node; S104: for the current root node having the same fingerprint in the first tree structure and the second tree structure, respectively obtain a first child node list under the current root node in the first tree structure and a second child node list under the current root node in the second tree structure, wherein the first child node list includes one or more first child nodes, and the second child node list includes one or more second child nodes; S105. Compare the fingerprint of the first subnode with the fingerprint of the second subnode; S106: When the fingerprint of the current first child node in the first child node list is different from the fingerprints of all the second child nodes in the second child node list, set the node state of the current first child node to a first state value, and add the node state to the node data of the current first child node; S107: When the fingerprint of the current second child node in the second child node list is different from the fingerprints of all the first child nodes in the first child node list, set the node state of the current second child node to a second state value, add the node state to the node data of the current second child node, and add the node data of the current second child node to a corresponding position in the first child node list; S108: When the fingerprint of the current first child node in the first child node list is the same as the fingerprint of the current second child node in the second child node list, determine whether the node data in the current first child node and the current second child node having the same fingerprint are consistent; S109: When the node data are consistent, the node state of the current first child node in the first child node list is set to a third state value, and the node state is added to the node data of the current first child node; S110: in the case where the node data is inconsistent, setting the node state of the current first child node in the first child node list to a fourth state value, and extracting the node data of the current second child node and adding it to the data change field of the current first child node; S111, using a current first child node with a node state of a fourth state value and a corresponding current second child node as current root nodes of the first tree structure and the second tree structure respectively; S112, determining whether the first child node list under the current root node of the first tree structure and the second child node list under the current root node of the second tree structure are both empty, if yes, proceeding to step S113, if no, proceeding to step S104; S113: Convert the first tree structure into a comparison result JS object representation file and store it in a database.

2. The method according to claim 1, characterized in that The method further comprises: Receive a query instruction input by a user, wherein the query instruction includes one or more of the following: a specified file name, a specified node fingerprint, a specified node status value, a specified field, a specified field keyword, and a specified tree structure range; Acquire a query result corresponding to the query instruction in the database; The query result is output to the user.

3. The method according to claim 1, characterized in that Step S102 includes: For the first JS object representing data: The root node of the data represented by the first JS object is used as the current node; Acquire current local data from node data of the current node, wherein the current local data does not include array type data; Generating nodes of the first tree structure for the current local data; In the case where the value of the current local data is array type data, taking a child node in the array type data as a new current node, and executing the steps of obtaining the current local data and generating a node of the first tree structure for the new current node; In the case where the value of the local data of each node of the generated first tree structure is not array type data, a complete first tree structure is generated, For the second JS object representing data: The root node of the data represented by the second JS object is used as the current node; Acquire current local data from node data of the current node, wherein the current local data does not include array type data; Generating nodes of the second tree structure for the current local data; In the case where the value of the current local data is array type data, taking a child node in the array type data as a new current node, and executing the steps of obtaining the current local data and generating a node of the second tree structure for the new current node; In the case where the value of the local data of each node of the generated second tree structure is not array type data, a complete second tree structure is generated.

4. The method according to claim 1, characterized in that: Step S103 includes: According to predefined rules, the values ​​of the fields in the predefined nodes are concatenated into a string as the fingerprint of the node.

5. The method according to claim 1, characterized in that Step S103 includes: Based on a predefined fingerprint calculation formula, the fingerprint of the node is calculated according to the value of the predefined field in the node.

6. The method according to claim 1, characterized in that Step S105 includes: Traversing the first child node list, and comparing the fingerprint of each first child node in the first child node list with the fingerprint of each second child node in the second child node list in sequence; The second child node list is traversed, and the fingerprint of each second child node in the second child node list is sequentially compared with the fingerprint of the first child node in the first child node list.

7. A JS object representation data processing device, characterized in that: The device comprises: A JS object representation data acquisition module, configured to acquire first JS object representation data and second JS object representation data, wherein the first JS object representation data and the second JS object representation data each include object type and array type data that can be nested with each other; A tree structure generating module, configured to generate a first tree structure and a second tree structure respectively according to the data type nesting structure in the first JS object representing the data and the second JS object representing the data; A fingerprint generation module configured to generate a fingerprint of each node in the first tree structure and the second tree structure according to a value of a predefined field in the node; a child node list acquisition module configured to obtain, for a current root node having the same fingerprint in the first tree structure and the second tree structure, a first child node list under the current root node in the first tree structure and a second child node list under the current root node in the second tree structure, respectively, wherein the first child node list includes one or more first child nodes, and the second child node list includes one or more second child nodes; a fingerprint comparison module, configured to compare the fingerprint of the first subnode with the fingerprint of the second subnode; a first state value setting module configured to set the node state of the current first child node to a first state value and add the node state to the node data of the current first child node when the fingerprint of the current first child node in the first child node list is different from the fingerprints of all the second child nodes in the second child node list; a second state value setting module, configured to, when the fingerprint of the current second child node in the second child node list is different from the fingerprints of all the first child nodes in the first child node list, set the node state of the current second child node to the second state value, add the node state to the node data of the current second child node, and add the node data of the current second child node to a corresponding position in the first child node list; a data consistency judgment module, configured to judge whether the node data in the current first child node and the current second child node having the same fingerprint are consistent when the fingerprint of the current first child node in the first child node list is the same as the fingerprint of the current second child node in the second child node list; A third state value setting module, configured to set the node state of the current first child node in the first child node list to a third state value when the node data are consistent, and add the node state to the node data of the current first child node; a fourth state value setting module, configured to set the node state of the current first child node in the first child node list to a fourth state value when the node data is inconsistent, and extract the node data of the current second child node and add it to the data change field of the current first child node; A current root node updating module, configured to use a current first child node with a node state of a fourth state value and a corresponding current second child node as current root nodes of the first tree structure and the second tree structure respectively; a child node list determination module, configured to determine whether the first child node list under the current root node of the first tree structure and the second child node list under the current root node of the second tree structure are both empty, if so, proceeding to the comparison result generation module, if not, proceeding to the child node list acquisition module; The comparison result generating module is configured to convert the first tree structure into a comparison result JS object representation file and store it in a database.

8. The device according to claim 7, characterized in that The device also includes a query module configured to: Receive a query instruction input by a user, wherein the query instruction includes one or more of the following: a specified file name, a specified node fingerprint, a specified node status value, a specified field, a specified field keyword, and a specified tree structure range; Acquire a query result corresponding to the query instruction in the database; The query result is output to the user.

9. A JS object representation data processing device, characterized in that: The device includes a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the JS object representation data processing method according to any one of claims 1 to 6 is implemented.

10. A storage medium storing computer-readable instructions, wherein when the instructions are executed by a processor, the method according to any one of claims 1 to 6 is executed.