JS object representation data processing method and device, equipment and storage medium
By parsing XML files into JSON format and storing them in the database, the problem of XML files being difficult to query and store on the front end of some systems is solved, and convenient data storage and query are achieved.
Patent Information
- Application Number
- CN202410121451.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-29
- Publication Date
- 2025-02-07
AI Technical Summary
During the vehicle research and development and manufacturing process, XML-format inspection specification files are difficult to directly query and store on the front end of some systems, resulting in inconvenience.
Parses and converts XML files into JS object representation (JSON) format and stores them in the database so that the system front-end is compatible.
It realizes effective parsing and storage of XML files, solves the compatibility problem of the front-end of the system for XML format, and facilitates subsequent query and reprocessing.
Smart Images

Figure CN119397059A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention generally relate to the field of vehicle data processing, and more specifically, to a JS object representation data processing method, apparatus, device and storage medium. Background Art
[0002] In the process of vehicle R&D and manufacturing, it is necessary to use documents such as electrical inspection specifications in the Extensible Markup Language (XML) format. Since some system front ends of manufacturers do not accept the XML format, it is inconvenient to query and store files.
[0003] However, it takes a lot of research and development resources and time to transform the existing system. Therefore, it is necessary to parse the XML file and store it in the JavaScript Object Notation (JSON) format that the system front end can be compatible with. 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: obtaining an extensible markup language file; taking the root node of the extensible markup language file as the extensible markup language current node; according to the format of the JS object representation data, converting the name of the extensible markup language current node into the name of the JS object representation current node; adding the node data of the extensible markup language current node into the value list of the JS object representation current node; judging whether the extensible markup language current node has a child node; in the case that the extensible markup language current node has a child node: taking the child node of the extensible markup language current node as the extensible markup language current node; setting the corresponding JS object representation current node addition position in its parent node according to the relationship between the extensible markup language current node and its parent node, and going to the step of converting the name of the extensible markup language current node into the name of the JS object representation current node; in the case that the extensible markup language current node does not have a child node, obtaining the parsed JS object representation data through the JS object representation node corresponding to the root node of the extensible markup language file; taking the root node of the JS object representation data as the current node to be stored, Add to the storage data as the current storage node; create a storage record and a universal unique identifier for the current storage node; obtain the path from the root node of the JS object representation data to the current node to be stored, and add the path to the storage record of the current storage node; obtain the identifier of the parent node of the current node represented by the JS object in the JS object representation data, and add it to the parent node field of the storage record of the current storage node; obtain the value list of the current node to be stored in the JS object representation data, and add it to the content field of the storage record of the current storage node; determine the value list of the current node to be stored in the JS object representation data Whether the current node to be stored has child nodes; in the case that the current node to be stored has child nodes: generate a child node value list based on the child node name and universal unique identifier of the current node to be stored; add the child node value list to the content field of the storage record of the current storage node; traverse the child nodes of the current node to be stored, take the child nodes of the current node to be stored as the current node to be stored, and go to the step of creating a storage record and universal unique identifier for the current storage node; in the case that the current node to be stored does not have child nodes: store the storage record of the current storage node corresponding to the current node to be stored in the database.
[0005] In some embodiments, the method further includes: receiving a query instruction, wherein the query instruction includes a universal unique identifier of a node to be queried; finding a storage record of the node to be queried in a database according to the universal unique identifier of the node to be queried; finding a path of the node to be queried in the storage record as the path to be queried; finding all storage records in the database that contain a string of the path to be queried as the storage records to be queried; and splicing the data in the record to be queried according to the association between the current storage node and the parent node field and the child node value list in the storage record to be queried, thereby obtaining query data.
[0006] In some embodiments, the method also includes: receiving a query instruction, wherein the query instruction includes a universal unique identifier of a node to be queried and an interceptor, wherein the interceptor includes a path string to be intercepted; finding a storage record of the node to be queried in a database according to the universal unique identifier of the node to be queried; finding the path of the node to be queried in the storage record as the path to be queried; finding all storage records in the database that contain the string of the path to be queried in the path as the storage records to be queried; removing the storage records that contain the path string to be intercepted in the interceptor from the storage records to be queried, and generating an intercepted storage record; according to the association between the current storage node and the parent node field and the child node value list in the intercepted storage record, splicing the data in the intercepted storage record to obtain the query data.
[0007] In some embodiments, after adding the node data of the current node of the extensible markup language to the value list of the JS object representing the current node, the method also includes: determining whether the current node of the extensible markup language has attributes; if the current node of the extensible markup language has attributes, adding the attributes of the current node of the extensible markup language to the attribute field of the current node represented by the JS object; if the current node of the extensible markup language does not have attributes, proceeding to the step of determining whether the current node of the extensible markup language has child nodes.
[0008] In some embodiments, the method further includes: when creating a storage record and a universal unique identifier for the current storage node, generating one or more of a storage record creation time field, a storage record update time field, and a database storage identifier field, and adding them to the storage record.
[0009] In the second aspect, the embodiment of the present invention proposes a JS object representation data processing device, the device comprising: an extensible markup language file acquisition module, configured to acquire an extensible markup language file; a root node parsing module, configured to use the root node of the extensible markup language file as the extensible markup language current node; a name conversion module, configured to convert the name of the extensible markup language current node into the name of the JS object representation current node according to the format of the JS object representation data; a value list adding module, configured to add the node data of the extensible markup language current node to the value list of the JS object representation current node; a child node parsing judgment module, configured to judge whether the extensible markup language current node has a child node; a child node parsing iteration module, configured to use the child node of the extensible markup language current node as the extensible markup language current node when the extensible markup language current node has a child node; a child node adding module, setting the corresponding JS object representation current node in its parent node according to the relationship between the extensible markup language current node and its parent node, and transferring to the name conversion module; a JS object representation data acquisition module, configured to acquire the JS object representation node corresponding to the root node of the extensible markup language file when the extensible markup language current node does not have a child node. The parsed JS object represents the data; a root node storage module, configured to use the root node of the JS object to represent the data as the current node to be stored, and add it to the stored data as the current storage node; a storage record creation module, configured to create a storage record and a universal unique identifier for the current storage node; a path acquisition module, configured to obtain the path from the root node of the JS object to represent the data to the current node to be stored, and add the path to the storage record of the current storage node; a parent node field adding module, configured to obtain the identifier of the parent node of the current node represented by the JS object in the JS object representation data, and add it to the parent node of the current storage node A content field adding module is configured to obtain the value list of the current node to be stored in the JS object representation data, and add it to the content field of the storage record of the current storage node; a storage child node judgment module is configured to judge whether the current node to be stored in the JS object representation data has a child node; a child node value list generation module is configured to generate a child node value list based on the child node name and universal unique identifier of the current node to be stored when the current node to be stored has a child node; a child node value list adding module is configured to add the child node value list to the content field of the storage record of the current storage node;A child node traversal module configured to traverse the child nodes of the current node to be stored, take the child nodes of the current node to be stored as the current node to be stored, and transfer to the storage record creation module; a storage record storage module configured to store the storage record of the current storage node corresponding to the current node to be stored in the database when the current node to be stored has no child nodes. ;
[0010] In some embodiments, the device also includes: a query instruction receiving module, configured to receive a query instruction, wherein the query instruction includes a universal unique identifier of a node to be queried; a storage record search module, configured to find the storage record of the node to be queried in a database according to the universal unique identifier of the node to be queried; a path determination module to be queried, configured to find the path of the node to be queried in the storage record as the path to be queried; a storage record acquisition module to be queried, configured to find all storage records in the database that contain the string of the path to be queried in the path as the storage record to be queried; a query data acquisition module, configured to splice the data in the record to be queried according to the association between the current storage node and the parent node field and the child node value list in the storage record to be queried, thereby obtaining the query data.
[0011] In some embodiments, the device also includes: a query instruction receiving module, configured to receive a query instruction, wherein the query instruction includes a universal unique identifier of the node to be queried and an interceptor, wherein the interceptor includes a path string to be intercepted; a storage record search module, configured to find the storage record of the node to be queried in the database according to the universal unique identifier of the node to be queried; a path determination module to be queried, configured to find the path of the node to be queried in the storage record as the path to be queried; a storage record acquisition module to be queried, configured to find all storage records containing the string of the path to be queried in the database as the storage record to be queried; an interception module, configured to be used for the storage record acquisition module to be queried, configured to remove the storage records containing the path string to be intercepted in the interceptor in the path of the storage record to be queried, and generate an intercepted storage record; a query data acquisition module, configured to splice the data in the intercepted storage record according to the association between the current storage node and the parent node field and the child node value list in the intercepted storage record, thereby obtaining the query data.
[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 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 method described in any of the above embodiments.
[0014] The JSON data processing method, device, equipment and storage medium proposed in the embodiments of the present invention parse XML files, convert them into data in JavaScript Object Notation (JSON) format acceptable to the system front end, and serialize and store them in a database to facilitate subsequent query and reprocessing operations. 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 1 A flowchart of a JS object representation data processing method according to an embodiment of the present invention is shown;
[0017] Figure 2 A flowchart of a JS object representation data query process in an example of a JS object representation data processing method according to an embodiment of the present invention is shown;
[0018] Figure 3 A flowchart of a JS object representation data query process in another example of a JS object representation data processing method according to an embodiment of the present invention is shown;
[0019] Figure 4 A block diagram showing a JS object representation data processing device according to an embodiment of the present invention.
[0020] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts. DETAILED DESCRIPTION
[0021] 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.
[0022] In one aspect, an embodiment of the present invention provides a method for processing JS Object Notation (JSON) data. Figure 1, which shows a flow chart of a JSON data processing method 100 according to an embodiment of the present invention. The method includes an Extensible Markup Language (XML) file parsing process and a JSON data storage process.
[0023] The XML file parsing process is used to parse the XML file into JSON data, and obtain JSON data containing complete XML data and structure by traversing all nodes of the XML data. Figure 1 As shown, the XML file parsing process includes steps S101-S108.
[0024] In step S101, an XML file is obtained.
[0025] In step S102, the root node of the XML file is used as the XML current node.
[0026] In step S103, according to the format of the JSON data, the name of the XML current node is converted into the name of the JSON current node. As an example only, the XML current node name is changed to lowercase, and "-" is changed to "_", and the changed node name is used as the parsed JSON current node name.
[0027] In step S104, the node data of the XML current node is added to the value list of the JSON current node. The node data of the XML current node includes text data, for example.
[0028] In step S105, it is determined whether the current XML node has a child node.
[0029] When the judgment in step S105 is yes, steps S106-S107 are executed.
[0030] In step S106, the child node of the XML current node is used as the XML current node.
[0031] In step S107, the adding position of the corresponding JSON current node in its parent node is set according to the relationship between the XML current node and its parent node, and then go to step S103.
[0032] When the determination in step S105 is No, step S108 is executed.
[0033] In step S108, the parsed JSON data is obtained through the JSON node corresponding to the root node of the XML file.
[0034] In the implementation of the above-mentioned XML file parsing process, optionally, after step S104, the method may further include: determining whether the XML current node has attributes; if the XML current node has attributes, adding the attributes of the XML current node to the attribute (attr) field of the JSON current node; if the XML current node does not have attributes, go to step S105.
[0035] The above XML file parsing process is exemplarily described below with reference to a specific example.
[0036] For example, the following is an example of an initial XML file:
[0037]
[0038]
[0039] It can be seen that in the original XML file, the root node is "PROCEDURES", the first-level child node is PROCEDURE, PROCEDURE includes the child node STEPS, STEPS includes the child node STEP, STEP includes the child nodes NAME, DIAG-SERVICE, and DIAG-PARAMETERS.
[0040] According to the XML parsing process in the JSON data processing method proposed in the embodiment of the present invention, the above XML file is parsed into the following JSON data:
[0041]
[0042]
[0043]
[0044] It can be seen that the node name is converted into the format of JSON data, the node data of each node is converted into a value list of each node in the JSON data, and the structured information between the parent node and the child node is reflected in the JSON data in a form that adapts to the JSON data format.
[0045] Next, continue to refer to Figure 1The JSON data storage process includes steps S109-S118. The JSON data storage process is used to create a universally unique identifier (UUID) for each node of the JSON data, and serialize and store the data of each node in a database (such as MongoDB) in a fixed format. The JSON data storage process uses the JSON data generated after XML parsing as an input parameter.
[0046] In step S109, the root node of the JSON data is used as the current node to be stored, and is added to the stored data as the current storage node.
[0047] In step S110, a storage record and a universal unique identifier (UUID) are created for the current storage node. For example, the UUID can be named "id_t" as a node unique identifier.
[0048] In step S111 , a path Xpath from the root node of the JSON data to the current node to be stored is obtained, and the path Xpath is added to the storage record of the current storage node.
[0049] In step S112, the identifier of the parent node of the current JSON node, that is, the id_t of the parent node, is obtained in the JSON data, and is added to the parent node (id_tParent) field of the storage record of the current storage node.
[0050] In step S113, a value list of the current node to be stored is obtained in the JSON data, and added to the content field of the storage record of the current storage node. The content field can be named as needed, for example, it can be named as a json field.
[0051] In step S114, it is determined whether the current node to be stored in the JSON data has a child node.
[0052] When the judgment in step S114 is yes, steps S115-S117 are executed.
[0053] In step S115 , a child node (id_children) value list is generated based on the child node name (nodeName) and the universal unique identifier (id_t) of the current node to be stored.
[0054] In step S116, the child node value list is added to the content field of the storage record of the current storage node.
[0055] In step S117, the child nodes of the current node to be stored are traversed, the child nodes of the current node to be stored are used as the current node to be stored, and the process goes to step S110.
[0056] When the determination in step S114 is NO, step S118 is executed.
[0057] In step S118, the storage record of the current storage node corresponding to the current node to be stored is stored in the database.
[0058] In the implementation of the above-mentioned JSON data storage process, optionally, the method may also include: when creating a storage record and a universal unique identifier for the current storage node, generating one or more of a storage record creation time (create_time) field, a storage record update time (update_time) field, and a database storage identifier (_id) field, and adding them to the storage record.
[0059] The above JSON data storage process creates a UUID for each node of the JSON data and names it id_t, and stores the data of each node in a fixed format in the database. The database can be a MongoDB database. The reason for choosing MongoDB as the storage database is that as a representative product in NoSQL, its functions and efficiency can be guaranteed, and it has a large user base. The most important thing is that it can directly serialize and store data in JSON format.
[0060] Taking the name node as an example, its original form in JSON data is as follows:
[0061]
[0062] The name node is stored in the database as follows:
[0063]
[0064]
[0065] Among them, _id is the unique identifier automatically generated when it is stored in the database, XPath is the absolute path of this node in XML / JSON, id_t is the UUID generated by the storage program for this node, create_time and update_time are the creation / update time of the node in the database, id_tParent is the id_t of the parent node, and json is the value of the node. For each node in the JSON data, it will be stored one by one in the following form, and the original parent-child node relationship of the JSON data will be associated with id_t through id_tParent, so it will not be lost or destroyed, and can be completely restored in subsequent JSON data queries.
[0066] If the current node contains a list of child nodes, the id_t and nodeName of the child nodes need to be added to the value list of the id_children field. This is explained below with a specific example.
[0067] The original form of the step node in JSON data is as follows:
[0068]
[0069]
[0070] The storage format of step nodes in the database is as follows:
[0071]
[0072]
[0073] Each node has a corresponding storage record in the database. The name (nodeName) and universal unique identifier (id_t) of the child node diag_service, name, and attr of the step node are added to the value list of the id_children field. The id_children field can be used to obtain the unique identifier of the child node diag_service, so as to find the storage record belonging to the child node diag_service based on the unique identifier.
[0074] The JSON data processing method proposed in the embodiment of the present invention parses the XML file, converts it into data in the JavaScript Object Notation (JSON) format acceptable to the system front end, and serializes and stores it in a database for subsequent query and reprocessing operations.
[0075] refer to Figure 2, which shows a flowchart of a JSON data query process 200 in an example of a JSON data processing method according to an embodiment of the present invention. The JSON data query program can query any local data of the JSON data. The JSON data query process 200 includes steps S201-S205. The JSON data query process 200 is used to extract the complete content of the data of a specified node and its specific descendant nodes in the JSON data through UUID for the data stored in the database, for subsequent data processing and front-end display.
[0076] In step S201, a query instruction is received, wherein the query instruction includes a universally unique identifier of a node to be queried.
[0077] In step S202, a storage record of the node to be queried is found in a database according to the universal unique identifier of the node to be queried.
[0078] In step S203, the path Xpath of the node to be queried is found in the storage record as the path to be queried.
[0079] In step S204, all storage records containing the character string of the path to be queried are found in the database as the storage records to be queried.
[0080] In step S205, according to the association between the current storage node and the parent node field (id_tParent) and the child node (id_children) value list in the storage record to be queried, the data in the record to be queried is concatenated to obtain the query data.
[0081] In the above data query process, the program first uses the id_t of the child node to be queried as the input parameter, and first finds the XPath of this node through MongoDB. Since the XPath of all child nodes of the current node contains the XPath of the current node, the data of all child nodes of the current node are filtered in the MongoDB database according to the following rules: If the XPath of the node in the database contains the XPath of the current node, the data of this node needs to be filtered and extracted. After all data are filtered and extracted, all data are spliced according to the association between id_t and id_tParent to obtain complete JSON data. Taking the step node data as an example, its id_t in the MongoDB database is "87d6d103-1949-4b67-9d47-32ad01f109ca". After executing the JSON data query program, the result is as follows, which is the complete step node JSON data.
[0082] The query result for the step node with id_t "87d6d103-1949-4b67-9d47-32ad01f109ca" is as follows, and the result is complete JSON data.
[0083]
[0084]
[0085] refer to Figure 3 , which shows a flowchart of a JSON data query process 300 in another example of a JSON data processing method according to an embodiment of the present invention. Figure 3 The embodiment shown is similar to Figure 2 The difference of the embodiment shown is that an interceptor is set during the query. The JSON data query process 300 extracts the complete content of the data of the specified node and its specific descendant nodes in the JSON data through the UUID and the interceptor for the data stored in the database, for subsequent data processing and front-end display. The JSON data query process 300 includes steps S301-S306.
[0086] In step S301, a query instruction is received, wherein the query instruction includes a universally unique identifier of a node to be queried and an interceptor, wherein the interceptor includes a path character string to be intercepted.
[0087] In step S302, a storage record of the node to be queried is found in a database according to the universal unique identifier of the node to be queried.
[0088] In step S303, a path of the node to be queried is found in the storage record as the path to be queried.
[0089] In step S304, all storage records containing the character string of the path to be queried are found in the database as the storage records to be queried.
[0090] In step S305, the storage records whose paths contain the path character string to be intercepted in the interceptor are removed from the storage records to be queried, and the intercepted storage records are generated.
[0091] In step S306, according to the association between the current storage node and the parent node field and the child node value list in the intercepted storage record, the data in the intercepted storage record is spliced to obtain the query data.
[0092] When using interceptors for direct query, the program uses interceptors as additional input parameters. Interceptors are a string list, and the values are XPath strings. Taking the step node with id_t as "87d6d103-1949-4b67-9d47-32ad01f109ca" as an example, when the interceptor is ["procedure / block / steps / step / diag_service"], after executing the JSON data query program, the results are as follows, which are local step node JSON data, and the data under the diag_service node is intercepted.
[0093] The query results for the step node with id_t "87d6d103-1949-4b67-9d47-32ad01f109ca" when using the interceptor are as follows. The results are local JSON data.
[0094]
[0095] The above-mentioned embodiment of the present invention proposes that the data of any local area of any node in the complete JSON data can be obtained by using the JSON data query process using id_t and interceptor as input parameters.
[0096] In another aspect, an embodiment of the present invention provides a JS object representation (JSON) data processing device. Figure 4 , which shows a block diagram of a JS object representation data processing device according to an embodiment of the present invention. The device includes modules 401-418.
[0097] The extensible markup language file acquisition module 401 may be configured to acquire an extensible markup language file.
[0098] The root node parsing module 402 may be configured to use the root node of the XML file as the XML current node.
[0099] The name conversion module 403 may be configured to convert the name of the current node in the extensible markup language into the name of the current node in the JS object representation according to the format of the JS object representation data.
[0100] The value list adding module 404 may be configured to add the node data of the current node of the extensible markup language to the value list of the current node represented by the JS object.
[0101] The parsing child node determination module 405 may be configured to determine whether the current extensible markup language node has a child node.
[0102] The sub-node parsing iteration module 406 may be configured to use the sub-node of the current XML node as the current XML node when the current XML node has a sub-node.
[0103] The child node adding module 407 can set a corresponding JS object to represent the adding position of the current node in its parent node according to the relationship between the current node and its parent node in the extensible markup language, and transfer the result to the name conversion module.
[0104] The JS object representation data acquisition module 408 may be configured to acquire the parsed JS object representation data through the JS object representation node corresponding to the root node of the XML file when the current XML node has no child nodes.
[0105] The root node storage module 409 may be configured to use the root node representing the data in a JS object as the current node to be stored, and add it to the stored data as the current storage node.
[0106] The storage record creation module 410 may be configured to create a storage record and a universal unique identifier for the current storage node.
[0107] The path acquisition module 411 may be configured to acquire a path from the root node of the JS object representation data to the current node to be stored, and add the path to the storage record of the current storage node.
[0108] The parent node field adding module 412 may be configured to obtain the identifier of the parent node of the current node represented by the JS object in the JS object representation data, and add it to the parent node field of the storage record of the current storage node.
[0109] The content field adding module 413 may be configured to obtain a value list of the current node to be stored in the JS object representation data, and add the value list to the content field of the storage record of the current storage node.
[0110] The storage child node determination module 414 may be configured to determine whether the current node to be stored in the JS object representation data has a child node.
[0111] The child node value list generating module 415 may be configured to generate a child node value list based on the child node name and the universal unique identifier of the current node to be stored when the current node to be stored has child nodes.
[0112] The subnode value list adding module 416 may be configured to add the subnode value list to the content field of the storage record of the current storage node.
[0113] The child node traversal module 417 may be configured to traverse the child nodes of the current node to be stored, take the child nodes of the current node to be stored as the current node to be stored, and transfer to the storage record creation module.
[0114] The storage record storage module 418 may be configured to store the storage record of the current storage node corresponding to the current storage node in the database when the current storage node has no child nodes.
[0115] As an embodiment of the present invention, the device may further include: a query instruction receiving module, a storage record searching module, a to-be-queried path determining module, a to-be-queried storage record acquiring module and a query data acquiring module.
[0116] The query instruction receiving module may be configured to receive a query instruction, wherein the query instruction includes a universally unique identifier of a node to be queried.
[0117] The storage record search module may be configured to find the storage record of the node to be queried in the database according to the universal unique identifier of the node to be queried.
[0118] The to-be-queried path determination module may be configured to find a path of the to-be-queried node in the storage records as the to-be-queried path.
[0119] The module for acquiring the storage records to be queried may be configured to find all the storage records in the database whose paths contain the character string of the path to be queried as the storage records to be queried.
[0120] The query data acquisition module may be configured to concatenate the data in the record to be queried according to the association between the current storage node and the parent node field and the child node value list in the storage record to be queried, thereby acquiring the query data.
[0121] As another embodiment of the present invention, the device may further include: a query instruction receiving module, a storage record searching module, a to-be-queried path determining module, a to-be-queried storage record acquiring module, an intercepting module and a query data acquiring module.
[0122] The query instruction receiving module may be configured to receive a query instruction, wherein the query instruction includes a universally unique identifier of a node to be queried and an interceptor, wherein the interceptor includes a path string to be intercepted.
[0123] The storage record search module may be configured to find the storage record of the node to be queried in the database according to the universal unique identifier of the node to be queried.
[0124] The to-be-queried path determination module may be configured to find a path of the to-be-queried node in the storage records as the to-be-queried path.
[0125] The module for acquiring the storage records to be queried may be configured to find all the storage records in the database whose paths contain the character string of the path to be queried as the storage records to be queried.
[0126] The interception module can be configured as a storage record acquisition module to be queried, configured to remove storage records whose paths contain the path string to be intercepted in the interceptor from the storage records to be queried, and generate intercepted storage records.
[0127] The query data acquisition module may be configured to concatenate the data in the intercepted storage record according to the association between the current storage node and the parent node field and the child node value list in the intercepted storage record, thereby acquiring the query data.
[0128] It should be noted that the functions implemented by each module in the JS object representation data device proposed in the embodiment of the present invention correspond one-to-one to the various steps of the JS object representation data method described above. For its specific implementation methods, examples and beneficial effects, please refer to the above description of the method.
[0129] On another aspect, an embodiment of the present invention proposes a JS object representation data processing device, which 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 described in any of the above embodiments is implemented.
[0130] 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.
[0131] The JSON data processing method, device, equipment and storage medium proposed in the embodiments of the present invention parse XML files, convert them into data in JavaScript Object Notation (JSON) format acceptable to the system front end, and serialize and store them in a database to facilitate subsequent query and reprocessing operations.
[0132] The JSON data query process in the JSON data processing method proposed in the embodiment of the present invention can obtain data of any local area of any node in the complete JSON data by using id_t or interceptor as an input parameter.
[0133] 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: Get the XML file; Using the root node of the extensible markup language file as the extensible markup language current node; According to the format of JS object representation data, converting the name of the current node of the extensible markup language into the name of the current node of the JS object representation; Adding the node data of the current node of the extensible markup language to the value list of the current node represented by the JS object; Determine whether the current node of the extensible markup language has a child node; In the case where the XML current node has child nodes: Taking the child node of the extensible markup language current node as the extensible markup language current node; According to the relationship between the current node of the extensible markup language and its parent node, a corresponding JS object is set to represent the adding position of the current node in its parent node, and the step of converting the name of the current node of the extensible markup language into the name of the current node represented by the JS object; In the case that the current node of the extensible markup language has no child nodes, obtaining the parsed JS object representation data through the JS object representation node corresponding to the root node of the extensible markup language file; The root node of the data represented by the JS object is used as the current node to be stored, and is added to the stored data as the current storage node; Creating a storage record and a universal unique identifier for the current storage node; Obtaining a path from the root node of the JS object representing the data to the current node to be stored, and adding the path to the storage record of the current storage node; Obtaining, from the JS object representation data, an identifier of a parent node of the current node represented by the JS object, and adding the identifier to a parent node field of a storage record of the current storage node; Obtaining the value list of the current node to be stored in the JS object representation data, and adding it to the content field of the storage record of the current storage node; Determine whether the current node to be stored in the data represented by the JS object has a child node; When the current node to be stored has child nodes: Generate a subnode value list based on the subnode name and the universal unique identifier of the current node to be stored; Adding the child node value list to the content field of the storage record of the current storage node; Traversing the child nodes of the current node to be stored, taking the child nodes of the current node to be stored as the current node to be stored, and going to the step of creating a storage record and a universal unique identifier for the current storage node; When the current node to be stored has no child nodes: The storage record of the current storage node corresponding to the current node to be stored is stored in the database.
2. The method according to claim 1, characterized in that The method further comprises: Receiving a query instruction, wherein the query instruction includes a universally unique identifier of a node to be queried; Finding a storage record of the node to be queried in a database according to the universal unique identifier of the node to be queried; Find the path of the node to be queried in the storage record as the path to be queried; Find all storage records in the database that contain the character string of the path to be queried as the storage records to be queried; According to the association between the current storage node and the parent node field and the child node value list in the storage record to be queried, the data in the record to be queried is spliced to obtain the query data.
3. The method according to claim 1, characterized in that The method further comprises: Receiving a query instruction, wherein the query instruction includes a universal unique identifier of a node to be queried and an interceptor, wherein the interceptor includes a path string to be intercepted; Finding a storage record of the node to be queried in a database according to the universal unique identifier of the node to be queried; Find the path of the node to be queried in the storage record as the path to be queried; Find all storage records in the database that contain the character string of the path to be queried as the storage records to be queried; Removing the storage records whose paths contain the character string of the path to be intercepted in the interceptor from the storage records to be queried, and generating the intercepted storage records; According to the association between the current storage node and the parent node field and the child node value list in the intercepted storage record, the data in the intercepted storage record is spliced to obtain the query data.
4. The method according to claim 1, characterized in that: After adding the node data of the current node of the extensible markup language to the value list of the current node represented by the JS object, the method further includes: Determine whether the current node of the extensible markup language has attributes; In the case that the extensible markup language current node has attributes, adding the attributes of the extensible markup language current node to the attribute field of the JS object representing the current node; In the case that the current XML node has no attribute, the process proceeds to the step of determining whether the current XML node has a child node.
5. The method according to claim 1, characterized in that: The method further comprises: When creating a storage record and a universal unique identifier for the current storage node, one or more of a storage record creation time field, a storage record update time field, and a database storage identifier field are generated and added to the storage record.
6. A JS object representation data processing device, characterized in that: The device comprises: An extensible markup language file acquisition module, configured to acquire an extensible markup language file; A root node parsing module configured to use the root node of the extensible markup language file as the extensible markup language current node; A name conversion module, configured to convert the name of the current node of the extensible markup language into the name of the current node represented by the JS object according to the format of the JS object representation data; A value list adding module, configured to add the node data of the current node of the extensible markup language to the value list of the current node represented by the JS object; A sub-node parsing judgment module configured to judge whether the current node of the extensible markup language has a sub-node; A sub-node parsing iteration module, configured to use the sub-node of the current extensible markup language node as the current extensible markup language node if the current extensible markup language node has a sub-node; A child node adding module sets a corresponding JS object to represent the adding position of the current node in its parent node according to the relationship between the current node and its parent node in the extensible markup language, and transfers to the name conversion module; A JS object representation data acquisition module configured to acquire the parsed JS object representation data through a JS object representation node corresponding to a root node of the extensible markup language file when the current node of the extensible markup language file has no child nodes; A root node storage module, configured to use the root node of the data represented by the JS object as the current node to be stored, and add it to the stored data as the current storage node; A storage record creation module, configured to create a storage record and a universal unique identifier for the current storage node; A path acquisition module, configured to acquire a path from a root node of the JS object representing data to the current node to be stored, and add the path to a storage record of the current storage node; A parent node field adding module is configured to obtain an identifier of a parent node of a current node represented by the JS object in the JS object representation data, and add the identifier to a parent node field of a storage record of the current storage node; A content field adding module, configured to obtain a value list of the current node to be stored in the JS object representation data, and add the value list to the content field of the storage record of the current storage node; A storage child node determination module is configured to determine whether the current node to be stored in the JS object representation data has a child node; A child node value list generating module, configured to generate a child node value list based on the child node name and the universal unique identifier of the current node to be stored, when the current node to be stored has child nodes; A subnode value list adding module, configured to add the subnode value list to the content field of the storage record of the current storage node; A child node traversal module, configured to traverse the child nodes of the current node to be stored, take the child nodes of the current node to be stored as the current node to be stored, and transfer to the storage record creation module; The storage record storage module is configured to store the storage record of the current storage node corresponding to the current storage node in the database when the current storage node has no child node.
7. The device according to claim 6, characterized in that The device also includes: A query instruction receiving module, configured to receive a query instruction, wherein the query instruction includes a universal unique identifier of a node to be queried; A storage record search module, configured to find the storage record of the node to be queried in the database according to the universal unique identifier of the node to be queried; A to-be-queried path determination module, configured to find a path of the to-be-queried node in the storage record as the to-be-queried path; A storage record acquisition module to be queried is configured to find all storage records in the database that contain the character string of the path to be queried as the storage record to be queried; The query data acquisition module is configured to concatenate the data in the record to be queried according to the association between the current storage node and the parent node field and the child node value list in the storage record to be queried, so as to acquire the query data.
8. The device according to claim 6, characterized in that The device also includes: A query instruction receiving module, configured to receive a query instruction, wherein the query instruction includes a universal unique identifier of a node to be queried and an interceptor, wherein the interceptor includes a path string to be intercepted; A storage record search module, configured to find the storage record of the node to be queried in the database according to the universal unique identifier of the node to be queried; A to-be-queried path determination module, configured to find a path of the to-be-queried node in the storage record as the to-be-queried path; A storage record acquisition module to be queried is configured to find all storage records in the database that contain the character string of the path to be queried as the storage record to be queried; An interception module, configured for a storage record acquisition module to be queried, configured to remove storage records whose paths contain the path string to be intercepted in the interceptor from the storage records to be queried, and generate intercepted storage records; The query data acquisition module is configured to splice the data in the intercepted storage record according to the association between the current storage node and the parent node field and the child node value list in the intercepted storage record, so as to obtain the query data.
9. A JS object representation data processing device, characterized in that: The device comprises 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 method according to any one of claims 1 to 5 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 5 is executed.