Method, device, equipment and storage medium for converting ARXML file into JSON file

By identifying the configuration node types in ARXML files and applying specific conversion rules to generate JSON files, the problem of lost semantic information in ECU configuration in existing technologies is solved, achieving efficient and accurate conversion of JSON files, which is suitable for modern ECU software development processes.

CN122491213APending Publication Date: 2026-07-31ZHEJIANG GEELY HLDG GRP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ZHEJIANG GEELY HLDG GRP CO LTD
Filing Date
2026-04-24
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

In existing technologies, when converting ARXML files to JSON files, the business meaning of each configuration node is not deeply understood, resulting in the loss of ECU configuration semantic information in the generated JSON file. This makes it difficult for modern ECU parameter management platforms, cloud calibration systems, and automated testing toolchains to use directly and efficiently.

Method used

By identifying the configuration node types in the ARXML file and generating JSON key-value pairs according to specific conversion rules for different node types, the nested structure of the JSON file is ensured to map the hierarchical relationship of ARXML, including the distinction between object-type and parameter-type nodes, as well as the standardization of reference paths.

Benefits of technology

The generated JSON file preserves the logical topology and business semantics of the ECU configuration, improving engineering usability and making it suitable for modern ECU software development processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122491213A_ABST
    Figure CN122491213A_ABST
Patent Text Reader

Abstract

This specification provides a method, apparatus, device, and storage medium for converting an ARXML file into a JSON file. The method includes: acquiring an ARXML file and converting the ARXML file into a DOM tree. For each configuration node in the DOM tree, determining the node type of the current configuration node. If the node type is one of a preset set of node types, generating a JSON key-value pair corresponding to the configuration node according to the conversion rule corresponding to the node type. Writing the JSON key-value pair into the corresponding position in the nested structure of the JSON file according to the hierarchical relationship of the current configuration node in the DOM tree.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of automotive electronic software engineering technology, and in particular to methods, apparatus, devices, and storage media for converting ARXML files into JSON files. Background Technology

[0002] AUTOSAR Classic Platform is currently the mainstream software architecture standard for automotive embedded ECU development worldwide. Its key configuration information, such as ECU resource description, hardware mapping relationship and service configuration parameters, are all defined based on ARXML files of Extensible Markup Language (XML).

[0003] With the rapid development of automotive intelligence and connectivity, the development process has generated a need for integration with ECU parameter management platforms, cloud calibration systems, and automated testing toolchains. These modern IT environments tend to use lightweight and easily parsed JSON data formats.

[0004] Therefore, achieving efficient and accurate conversion of ECU configuration-related ARXML data to JSON format has become a key technical link connecting traditional automotive electronic design with modern ECU software development processes. Summary of the Invention

[0005] To overcome the problems existing in related technologies, this specification provides methods, apparatus, devices and storage media for converting ARXML files into JSON files.

[0006] According to a first aspect of the embodiments of this specification, a method for converting an ARXML file into a JSON file is provided, the method comprising: Obtain the ARXML file and convert it into a DOM tree; For each configuration node in the DOM tree, determine the node type of the current configuration node; If the node type is one of the preset node types, then according to the conversion rules corresponding to the node type, a JSON key-value pair corresponding to the configuration node is generated; According to the current configuration node's hierarchical position in the DOM tree, the JSON key-value pairs are written to the corresponding positions in the nested structure of the JSON file.

[0007] According to a second aspect of the embodiments of this specification, an apparatus for converting an ARXML file into a JSON file is provided, the apparatus comprising: The file conversion module is used to obtain ARXML files and convert the ARXML files into DOM trees; The node type determination module is used to determine the node type of the current configuration node for each configuration node in the DOM tree; The key-value pair generation module is used to generate JSON key-value pairs corresponding to the configuration node according to the conversion rules corresponding to the node type if the node type is one of the preset node type sets. The key-value pair writing module is used to write the JSON key-value pairs into the corresponding positions in the nested structure of the JSON file according to the hierarchical relationship of the currently configured node in the DOM tree.

[0008] According to a third aspect of the embodiments of this specification, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the method as described in the first aspect.

[0009] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the method as described in the first aspect.

[0010] The technical solutions provided in the embodiments of this specification may include the following beneficial effects: In the embodiments of this specification, before mapping configuration nodes to JSON key-value pairs, the node type of the configuration node is determined. Different node types employ different conversion rules. When the node type is one of the preset node types, JSON key-value pairs corresponding to the configuration node are generated according to the conversion rules corresponding to the node type. This ensures that the generated JSON key-value pairs conform to the business logic and configuration intent of the corresponding configuration node type. By writing the JSON key-value pairs into the corresponding positions in the nested structure of the JSON file according to the hierarchical relationship of the current configuration node in the DOM tree, it is ensured that the nested structure of the generated JSON file maps the hierarchical relationship between different configuration nodes in ARXML.

[0011] As can be seen, this embodiment constructs a JSON structure by identifying the type of ARXML configuration nodes and the hierarchical relationship between different configuration nodes, so that the final generated JSON structure has high engineering usability.

[0012] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description

[0013] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this specification and, together with the description, serve to explain the principles of this specification.

[0014] Figure 1 This is a schematic diagram illustrating the configuration content of an ARXML file according to an exemplary embodiment of this specification.

[0015] Figure 2 This is a flowchart illustrating a method for converting an ARXML file into a JSON file according to an exemplary embodiment of this specification.

[0016] Figure 3 This is a schematic diagram illustrating an interface call flow for converting an ARXML file to a JSON file, according to an exemplary embodiment of this specification.

[0017] Figure 4 This is a schematic diagram illustrating another interface call flow for converting an ARXML file to a JSON file, according to an exemplary embodiment of this specification.

[0018] Figure 5 This is a schematic diagram illustrating another interface call flow for converting an ARXML file to a JSON file, according to an exemplary embodiment of this specification.

[0019] Figure 6 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment of this specification.

[0020] Figure 7 This is a block diagram illustrating an apparatus for converting an ARXML file into a JSON file according to an exemplary embodiment of this specification. Detailed Implementation

[0021] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this specification as detailed in the appended claims.

[0022] The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of this specification. The singular forms “a,” “the,” and “the” as used in this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.

[0023] It should be understood that although the terms first, second, third, etc., may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."

[0024] AUTOSAR Classic Platform is currently the mainstream software architecture standard for automotive embedded ECU development worldwide. Its key configuration information, such as ECU resource description, hardware mapping relationship and service configuration parameters, are all defined based on ARXML files of Extensible Markup Language (XML).

[0025] With the rapid development of automotive intelligence and connectivity, the development process has generated a need for integration with ECU parameter management platforms, cloud calibration systems, and automated testing toolchains. These modern IT environments tend to use lightweight and easily parsed JSON data formats.

[0026] Therefore, achieving efficient and accurate conversion of ECU configuration-related ARXML data to JSON format has become a key technical link connecting traditional automotive electronic design with modern ECU software development processes.

[0027] like Figure 1 As shown, the structure of an ARXML file is illustrated with a simple example. In this scheme, the configuration node is <...>...< / ...> The naming of different configuration nodes can conform to the specifications of the AUTOSAR metamodel, so that the business identity of different configuration nodes can be distinguished based on the tag content in the configuration node. This application does not restrict the naming rules of configuration nodes. For example, <ecuc-module-configuration-values>The tag contains the field "module", indicating that the configuration value stored by this configuration node is of module type. For example, <ecuc-container-value>This tag includes the field "CONTAINER," indicating that the configuration value stored by this configuration node is a container. For example, <ecuc-numerical-param-value>This tag contains the field "PARAM", indicating that the configuration value stored in this configuration node is of parameter type. For example, <definition-ref>This tag includes the field "ref", indicating that the configuration value stored in this configuration node is the address of another container or module that it references. For example, <value>The label contains a field "value", indicating that the configuration value stored in this configuration node is a parameter value. The data type of this parameter value is determined by the data type of the label record in the parent node. <short-name>This indicates the name of the storage container or module in this configuration node.

[0028] Existing technologies for converting ARXML files to JSON files do not deeply understand the business meaning of each configuration node. Instead, they use general conversion rules to perform a shallow syntactic structure mapping on all configuration nodes. This results in the loss of ECU configuration semantic information in the final JSON file, making it difficult for modern ECU parameter management platforms, cloud calibration systems, and automated testing toolchains to use directly and efficiently.

[0029] To address the aforementioned technical problems, this application proposes a method for converting ARXML files into JSON files.

[0030] The embodiments described in this specification will now be described in detail.

[0031] Figure 2 This is a flowchart illustrating a method for converting an ARXML file to a JSON file according to an exemplary embodiment. Figure 2 As shown, steps 201-204 are included: Step 201: Obtain the ARXML file and convert the ARXML file into a DOM tree.

[0032] Step 202: For each configuration node in the DOM tree, determine the node type of the current configuration node.

[0033] Step 203: If the node type is one of the preset node types, then generate a JSON key-value pair corresponding to the configuration node according to the conversion rule corresponding to the node type.

[0034] Step 204: According to the hierarchical relationship of the current configuration node in the DOM tree, write the JSON key-value pairs into the corresponding positions in the nested structure of the JSON file.

[0035] In this embodiment, before mapping configuration nodes to JSON key-value pairs, the node type of the configuration node is determined. Different node types employ different conversion rules. When the node type is one of the preset node types, JSON key-value pairs corresponding to the configuration node are generated according to the conversion rules corresponding to the node type. This ensures that the generated JSON key-value pairs conform to the business logic and configuration intent of the corresponding configuration node type. By writing the JSON key-value pairs into the corresponding positions in the nested structure of the JSON file according to the current hierarchy of the configuration node in the DOM tree, it is ensured that the nested structure of the generated JSON file maps the hierarchical relationship between different configuration nodes in ARXML.

[0036] As can be seen, this embodiment constructs a JSON structure by identifying the type of ARXML configuration nodes and the hierarchical relationship between different configuration nodes, so that the final generated JSON structure has high engineering usability.

[0037] In one embodiment, when determining the node type of the current configuration node, the label of the current configuration node can be extracted, and the node type of the configuration node can be determined based on the label. For example, the node type of the configuration node can be determined based on the built-in AUTOSAR ECU meta-model.

[0038] In this embodiment, tags of the same node type can use the same name. For example, if the node type is a container, then all containers in the ARXML file will use a unique tag. <ecuc-container-value>This is used to indicate that the type of the configuration node is a container.

[0039] In this embodiment, since the tag name adopts a structural feature of mandatory constraints, the node type of the configuration node can be determined by directly reading the tag. This can eliminate the recognition error caused by differences in file content and ensure the universality of this solution for recognizing the type of configuration nodes in ARXML files from different sources.

[0040] In one embodiment, the preset node type set may include object-type nodes and parameter-type nodes. Object-type nodes may include module nodes and container nodes. When generating JSON key-value pairs corresponding to configuration nodes according to the conversion rules corresponding to node types, if the node type is an object-type node, a first JSON key-value pair of object type corresponding to the configuration node can be generated according to the conversion rules corresponding to object-type nodes. If the node type is a parameter-type node, a second JSON key-value pair of parameter type corresponding to the configuration node can be generated according to the conversion rules corresponding to parameter-type nodes.

[0041] The difference between the first and second JSON key-value pairs lies in the structure of the values. The value of the first JSON key-value pair can be an object structure {}, while the value of the second JSON key-value pair can be a parameter.

[0042] For example, see Figure 1 During the traversal to <ecuc-module-configuration-values>At that time, the first JSON key-value pair generated was "Can: {}". However, when iterating to... <ecuc-numerical-param-value>At that time, the generated second JSON key-value pair is "$ref: #... / Baudrate" and "value: 500".

[0043] In this embodiment, by distinguishing between object-type nodes and data-type nodes, and generating corresponding first JSON key-value pairs or second JSON key-value pairs for the two different types of nodes, the converted JSON key-value pairs accurately reconstruct the logical topology structure of the ECU configuration in ARXML.

[0044] In one embodiment, if the node type is not one of the preset node type sets, it is skipped. For example, for redundant configuration nodes in the ARXML file that have no actual configuration value, such as... Figure 1 In <containers> 、 <sub-containers>By identifying these redundant configuration nodes based on their node types and ignoring them during the key-value pair generation stage, the final JSON nested structure is flattened.

[0045] In one embodiment, if the tag of a configuration node contains attributes, key-value pairs are constructed for those attributes. For example, for a container defined in ARXML via EECUC-MODULE-CONFIGURATION-VALUES (modules). <ecuc-container-value uuid="..."> <short-name> name< / short-name> < / ecuc-container-value> A general converter might generate {"ECUC-CONTAINER-VALUE":{"@UUID":"...","SHORT-NAME":"name"}}. This embodiment, however, elevates the attributes to generate a more concise and semantically clear JSON structure, such as {"ECUC-CONTAINER-VALUE":{"UUID":"...","SHORT-NAME":"name"}}, or even further normalized to {"name":{"UUID":"..."}}.

[0046] In one embodiment, when generating a first JSON key-value pair of object type corresponding to a configuration node according to the conversion rules corresponding to the object-type node, the named child node at the next level of the configuration node can be found, and the name stored in the named child node can be used as the key of the first JSON key-value pair. An empty object is created as the value of the first JSON key-value pair, and the structure of the object is used to store the configuration value extracted from the child node of the configuration node.

[0047] For example, see Figure 1 During the traversal to <ecuc-module-configuration-values>Find the named child nodes of the next level of this configuration node. <short-name>The name stored in the named child node is used as the key of the first JSON key-value pair for this configuration node, and an empty object is created as the value of the first JSON key-value pair. For example, Can: {}. Based on the same operation, the first JSON key-value pairs for other containers can be created, such as CanConfigSet: {}, CanController_0: {}. The object structure {} can be filled with configuration values ​​extracted from the child nodes of the configuration node; details can be found in... Figure 2 This is implemented in step 204.

[0048] In existing technologies, general converters typically use XML tag names directly, such as... <ecuc-module-configuration-values>As the key in a JSON key-value pair, the final result may be: <ecuc-module-configuration-values>{"SHORT-NAME":"Can",...}. In this embodiment, after identifying the configuration node as an object type, it further searches for the named child nodes at the next level of the configuration node and uses the name stored in the named child node as the key of the first JSON key-value pair, so that the generated key-value pair restores the business semantics of the configuration data.

[0049] In one embodiment, parameter nodes may include value nodes and reference nodes. When generating a second JSON key-value pair of the parameter type corresponding to the configuration node according to the conversion rules corresponding to the parameter node, if the node type of the configuration node is a value node, the target data type corresponding to the value of the second JSON key-value pair is determined according to the tag of the configuration node, the value parameter is extracted from the value child node of the next level of the configuration node, and the value parameter is converted into the target data type to generate the second JSON key-value pair corresponding to the value parameter.

[0050] For example, see Figure 1 For configuration nodes <ecuc-numerical-param-value>Its node type is a value node. Based on the label of the configuration node, it can be determined that the target data type corresponding to the value of the second JSON key-value pair is numeric. This is determined from the value child nodes of the next level of the configuration node. <value>Extract the value parameter 500, convert the value parameter to a numeric type, and generate the second JSON key-value pair corresponding to the value parameter, i.e., value: 500.

[0051] The data type recorded in the labels of value nodes can also include boolean, text, and other types. For example, <ecuc-textual-param-value>This indicates that the node type of the configuration node is a value node and the data type is text.

[0052] Existing general conversion tools typically extract directly. <value>The value parameter in the JSON file is not converted to a different data type. For example, boolean values ​​are usually represented as "1" or "0" in ARXML files, while they are usually represented as "true" or "false" in JSON files. Without data type conversion, logical errors will occur when using JSON files.

[0053] In this embodiment, by further distinguishing parameter nodes into value nodes and reference nodes, and identifying the data type of the parameters recorded in the value nodes based on the content of the tags, the data type of the parameters in the XML is actively mapped when converting to JSON format, thus eliminating ambiguity in the converted data.

[0054] If the configuration node is a reference node, the reference path parameter is extracted from the configuration node, the normalized path parameter corresponding to the reference path parameter is searched in the global path registry, and a second JSON key-value pair corresponding to the reference path parameter is generated based on the normalized path parameter.

[0055] For example, see Figure 1 For configuration nodes <definition-ref>Its node type is a reference node. The reference path parameter ... / Baudrate can be extracted from the configuration node. The normalized path parameter corresponding to the reference path parameter can be found in the global path registry. Based on the normalized path parameter, a second JSON key-value pair corresponding to the reference path parameter is generated, namely $ref: #... / Baudrate.

[0056] The relationship between standardized path parameters and referenced path parameters can be achieved by adding "#" at the beginning of the referenced path parameter to indicate that it is a reference type of data, which is helpful for tools that call JSON files to identify it.

[0057] In this embodiment, by converting the reference path parameter into a standardized path parameter, tools using JSON files can automatically recognize the data as an internal reference rather than a text string, thus eliminating ambiguity in data parsing.

[0058] In one embodiment, the global path registry also stores the reference object referenced by the reference path parameter. When generating the second JSON key-value pair corresponding to the reference path parameter based on the normalized path parameter, the global path registry is checked to see if the reference object corresponding to the normalized path parameter exists. If it exists, the normalized path parameter is used as the value in the second JSON key-value pair; otherwise, the value in the second JSON key-value pair is set to empty.

[0059] For example, refer to Figure 1 For the reference path parameter ... / Baudrate, its corresponding normalized path parameter in the global path registry is #... / Baudrate, and the referenced object referenced by the reference path parameter is Baudrate. If the referenced object corresponding to the normalized path parameter does not exist in the global path registry, the generated second JSON key-value pair is $ref: Null, where the value in the second JSON key-value pair is set to empty. If the referenced object corresponding to the normalized path parameter exists in the global path registry, the generated second JSON key-value pair is $ref: #... / Baudrate, where #... / Baudrate is the value in the second JSON key-value pair.

[0060] In this embodiment, before mapping the reference path in the ARXML file to the JSON file, the existence of the referenced object referenced by the reference path is verified through the set global path registry. This is to prevent engineers from deleting the referenced object referenced by the reference path in the ARXML file but forgetting to delete the references to it elsewhere, which would cause the corresponding referenced object to be inaccessible when accessing the standardized path parameters generated in the JSON file, resulting in program abnormalities.

[0061] In one embodiment, before converting the ARXML file to a JSON file, a global path registry can be created. For example, each configuration node in the DOM tree can be traversed. If multiple configuration nodes of the same name with the same reference node type exist under the same parent node, the reference path parameters recorded by each configuration node are converted into normalized path parameters containing indexes, and the normalized path parameters containing indexes are stored in the global path registry.

[0062] For example, the reference path parameter ECU / Os / Alarm referenced by three reference nodes with the same name under the same parent node can be converted into normalized path parameters #ECU / Os / Alarm / 0, #ECU / Os / Alarm / 1, and #ECU / Os / Alarm / 2, which include indexes. Here, 0, 1, and 2 are used to distinguish the index positions of each reference node with the same name under the parent node.

[0063] In this embodiment, by setting an index for the same-name reference path parameter, the downstream system can directly locate the target object by means of the numeric index when parsing the reference object without having to traverse and perform string matching to parse the reference object.

[0064] In one embodiment, the node type includes object nodes, which include module nodes and container nodes. If the node type of a configuration node is a module node and the module name of the configuration node does not belong to a preset module set, then the configuration node and its child nodes are skipped.

[0065] The preset module set can include the ECU configuration modules that the user specifies need to be converted this time. The selection of modules in the preset module set can be freely set according to the task scenario of different development stages.

[0066] In this embodiment, the above filtering strategy can realize the on-demand conversion of ECU configuration data, avoid invalid parsing of massive amounts of irrelevant data in ARXML files, effectively eliminate redundant configuration data that is irrelevant to the user's current development task, achieve lightweight output results, and avoid the waste of resources caused by full conversion.

[0067] In one embodiment, when writing JSON key-value pairs to the corresponding positions in the nested structure of a JSON file according to the hierarchical relationship of the current configuration node in the DOM tree, if the current configuration node has a parent node, the first or second JSON key-value pair corresponding to the configuration node can be written into the object structure of the first JSON key-value pair corresponding to the parent node.

[0068] For example, see again Figure 1 During the traversal to <ecuc-module-configuration-values>When the first JSON key-value pair generated is Can: {}, no operation is performed since it has no parent node.

[0069] During the traversal <ecuc-container-value>When the first JSON key-value pair is generated, it is CanConfigSet: {}. Since its parent node is Can, the first JSON key-value pair can be written into the object structure of Can. The nested structure of the JSON file formed is Can: {CanConfigSet: {}}.

[0070] During the traversal <ecuc-container-value>At that time, the first JSON key-value pair generated is CanController_0: {}. Since its parent node is CanConfigSet, this first JSON key-value pair can be written into the CanConfigSet object structure. The nested structure of the current JSON file is Can: {CanConfigSet: {CanController_0: {}}}.

[0071] During the traversal <ecuc-numerical-param-value>At that time, the corresponding second JSON key-value pair generated is value: 500. Since its parent node is CanController_0, the second JSON key-value pair can be written into the object structure of CanController_0. The nested structure of the current JSON file is Can: {CanConfigSet: {CanController_0: {value: 500}}}.

[0072] During the traversal <definition-ref>At that time, the corresponding second JSON key-value pair generated is $ref: #... / Baudrate. Since its parent node is CanController_0, the corresponding second JSON key-value pair can be written into the object structure of CanController_0. The nested structure of the currently formed JSON file is Can: {CanConfigSet: {CanController_0: {ref: #... / Baudrate, value: 500}}}.

[0073] After the iteration is complete, the final nested structure of the generated JSON file is: Can: {CanConfigSet: {CanController_0: {$ref: #... / Baudrate, value: 500}}}.

[0074] In this embodiment, the nested structure of the generated JSON file can be mapped to the hierarchical relationship between different configuration nodes of ARXML using the above method.

[0075] Next, we will use real-world development scenarios as examples to illustrate: like Figure 3 As shown, the logic for determining the node type of each configuration node can be integrated into the metamodel recognizer. This recognizer can have a built-in list of core metamodels defining ECU configurations in the UTOSAR Classic Platform to implement this logic. For the node type identified by the metamodel recognizer, a rule application engine calls the corresponding conversion rules from a dedicated rule mapping library. This rule application engine can be used to perform name mapping and data type conversion in the second JSON key-value pairs. After generating the second JSON key-value pairs, a structure generator can be used to write the JSON key-value pairs to the corresponding positions in the nested structure of the JSON file according to the hierarchical relationship of the current configuration node in the DOM tree. Of course, optimization functions such as attribute promotion, flattening nested structures, and compressing redundant levels can also be implemented internally within the structure generator.

[0076] like Figure 4 As shown, in Figure 3 Based on this, a module filtering controller can be set up to implement a module filtering strategy based on the preset module set set by the user through the configuration interface. This allows for the conversion of modules in the preset module set, while nodes and their child nodes that do not belong to the target module are skipped directly.

[0077] like Figure 5 As shown, in Figure 3 Building upon this foundation, processing logic for configuration nodes with reference-type nodes can be added. For example, a global path registry can be created in memory, and its construction process can include indexing and orchestrating similar configuration nodes. During key generation, in addition to recording the complete SHORT-NAME path, indexes can be automatically compiled for configuration nodes with the same name under the same parent node. For instance, when the global path registry finds three similar reference objects under the reference path parameter / ECU / Os / OsAlarm, it will automatically record them as: " / ECU / Os / OsAlarm / 0" (reference to the first OsAlarm object), " / ECU / Os / OsAlarm / 1" (reference to the second OsAlarm object), and " / ECU / Os / OsAlarm / 2" (reference to the third OsAlarm object). Their values ​​are the memory references of that configuration node in the JSON object graph being constructed.

[0078] During the parsing process, for nodes of reference type, such as... <value-ref dest="ECUC-CONTAINER-VALUE"> / ECU / Os / Alarm< / value-ref> The reference path / ECU / Os / Alarm can be extracted and converted into a standardized path format starting with "#", i.e., # / ECU / Os / Alarm. The # symbol explicitly identifies this as an internal reference pointer, rather than a regular string.

[0079] When encountering a configuration node that is a reference node, the global path registry can be queried for precise location. When pointing to a unique object, the normalized path # / ECU / Os is queried, and the global path registry returns a unique Os configuration object reference. When pointing to a specific object in a list, the path # / ECU / Os / OsAlarm / 1 is queried, and the global path registry will directly return the second object in the OsAlarm list (index starts from 0). This is the core of "indicating the position of the referenced object within the same group of type elements". Subsequently, a standard reference identifier {"$ref": "# / ECU / Os / OsAlarm / 1"} is generated to replace the original path. This method preserves the document structure while achieving precise indexed location.

[0080] Corresponding to the embodiments of the foregoing methods, this specification also provides embodiments of the apparatus and the terminal to which it is applied.

[0081] Figure 6 This is a schematic diagram illustrating the structure of an electronic device according to an exemplary embodiment. Figure 6 As shown, at the hardware level, the electronic device 600 includes a processor 602, an internal bus 604, a network interface 606, memory 608, and non-volatile memory 610, and may also include other hardware required for business operations. One or more embodiments of this specification can be implemented in software, for example, the processor 602 reads the corresponding computer program from the non-volatile memory 610 into memory 608 and then runs it. Of course, in addition to software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to each logic module, but can also be hardware or logic devices.

[0082] Figure 7 This is a block diagram illustrating an apparatus for converting an ARXML file to a JSON file according to an exemplary embodiment of this specification. Figure 7 As shown, this device can be applied to, for example Figure 6 The electronic device 600 shown implements the technical solution of this specification. The device includes: The file conversion module 702 is used to obtain an ARXML file and convert the ARXML file into a DOM tree.

[0083] The node type determination module 704 is used to determine the node type of the current configuration node for each configuration node in the DOM tree.

[0084] The key-value pair generation module 706 is used to generate JSON key-value pairs corresponding to the configuration node according to the conversion rules corresponding to the node type if the node type is one of the preset node type sets.

[0085] The key-value pair writing module 708 is used to write the JSON key-value pairs to the corresponding positions in the nested structure of the JSON file according to the hierarchical relationship of the current configuration node in the DOM tree.

[0086] Optionally, the node type determination module 704 is specifically used to extract the label of the current configuration node and determine the node type of the configuration node based on the label.

[0087] Optionally, the preset node type set includes object-type nodes and parameter-type nodes. Specifically, the key-value pair generation module 706 is used to generate a first JSON key-value pair of the object type corresponding to the configuration node, based on the conversion rules corresponding to the object-type node, if the node type is an object-type node. If the node type is a parameter-type node, it generates a second JSON key-value pair of the parameter type corresponding to the configuration node, based on the conversion rules corresponding to the parameter-type node.

[0088] Optionally, the key-value pair generation module 706 is specifically used to find the named child node of the next level of the configuration node, and use the name stored in the named child node as the key of the first JSON key-value pair; create an empty object as the value of the first JSON key-value pair, and the structure of the object is used to store the configuration value extracted from the child node of the configuration node.

[0089] Optionally, the key-value pair writing module 708 is specifically used to write the first JSON key-value pair or the second JSON key-value pair corresponding to the configuration node into the object structure of the first JSON key-value pair corresponding to the parent node if the current configuration node has a parent node.

[0090] Optionally, the parameter-type node includes value-type nodes and reference-type nodes. The key-value pair generation module 706 is specifically used to: if the node type of the configuration node is a value-type node, determine the target data type corresponding to the value of the second JSON key-value pair based on the tag of the configuration node, extract the value parameter from the value child node of the next level of the configuration node, convert the value parameter to the target data type, and generate the second JSON key-value pair corresponding to the value parameter; or, if the node type of the configuration node is a reference-type node, extract the reference path parameter from the configuration node, search for the normalized path parameter corresponding to the reference path parameter in the global path registry, and generate the second JSON key-value pair corresponding to the reference path parameter based on the normalized path parameter.

[0091] Optionally, the global path registry also stores reference objects referenced by the reference path parameters. The key-value pair generation module 706 is specifically used to query whether the reference object corresponding to the standardized path parameter exists in the global path registry. If it exists, the standardized path parameter is used as the value in the second JSON key-value pair. Otherwise, the value in the second JSON key-value pair is set to empty.

[0092] Optionally, the device further includes a path registry construction module for traversing each configuration node of the DOM tree; if there are multiple configuration nodes of the same name under the same parent node, the reference path parameters recorded by each configuration node are converted into normalized path parameters containing indexes, and the normalized path parameters containing indexes are stored in the global path registry.

[0093] Optionally, the node type includes object-type nodes, which include module nodes and container nodes. The device further includes a module filtering module, which is used to skip the configuration node and its child nodes if the node type of the configuration node is a module node and the module name of the configuration node does not belong to a preset module set.

[0094] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.

[0095] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0096] This specification also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the foregoing methods for converting ARXML files to JSON files provided in this application.

[0097] Specifically, computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROM and DVD-ROM disks.

[0098] This specification also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of any of the aforementioned methods for converting an ARXML file to a JSON file. < / value> < / value> < / containers> < / value>

Claims

1. A method for converting an ARXML file to a JSON file, characterized in that, The method includes: Obtain the ARXML file and convert it into a DOM tree; For each configuration node in the DOM tree, determine the node type of the current configuration node; If the node type is one of the preset node types, then according to the conversion rules corresponding to the node type, a JSON key-value pair corresponding to the configuration node is generated; According to the current configuration node's hierarchical position in the DOM tree, the JSON key-value pairs are written to the corresponding positions in the nested structure of the JSON file.

2. The method according to claim 1, characterized in that, Determining the node type of the current configuration node includes: Extract the label of the current configuration node, and determine the node type of the configuration node based on the label.

3. The method according to claim 1, characterized in that, The preset node type set includes object-type nodes and parameter-type nodes. The step of generating JSON key-value pairs corresponding to the configuration node according to the conversion rules corresponding to the node type includes: If the node type is an object node, then according to the conversion rule corresponding to the object node, a first JSON key-value pair of the object type corresponding to the configuration node is generated; If the node type is a parameter node, then according to the conversion rules corresponding to the parameter node, a second JSON key-value pair of the parameter type corresponding to the configuration node is generated.

4. The method according to claim 3, characterized in that, The step of generating a first JSON key-value pair of the object type corresponding to the configuration node according to the conversion rule corresponding to the object type node includes: Locate the named child node at the next level of the configuration node, and use the name stored in the named child node as the key of the first JSON key-value pair; An empty object is created as the value of the first JSON key-value pair, and the structure of the object is used to store the configuration values ​​extracted from the child nodes of the configuration node.

5. The method according to claim 3, characterized in that, The step of writing the JSON key-value pairs into the corresponding positions in the nested structure of the JSON file according to the current configuration node's hierarchical relationship in the DOM tree includes: If the current configuration node has a parent node, then the first JSON key-value pair or the second JSON key-value pair corresponding to the configuration node is written into the object structure of the first JSON key-value pair corresponding to the parent node.

6. The method according to claim 3, characterized in that, The parameter-type nodes include value-type nodes and reference-type nodes. The step of generating a second JSON key-value pair of the parameter type corresponding to the configuration node according to the conversion rule corresponding to the parameter-type node includes: If the configuration node is a value-type node, then the target data type corresponding to the value of the second JSON key-value pair is determined according to the label of the configuration node. The value parameter is extracted from the child nodes of the next level of the configuration node, and after converting the value parameter to the target data type, a second JSON key-value pair corresponding to the value parameter is generated; or, If the node type of the configuration node is a reference node, then the reference path parameter is extracted from the configuration node, the standardized path parameter corresponding to the reference path parameter is searched in the global path registry, and a second JSON key-value pair corresponding to the reference path parameter is generated based on the standardized path parameter.

7. The method according to claim 6, characterized in that, The global path registry also stores the referenced objects referenced by the reference path parameters. The step of generating a second JSON key-value pair corresponding to the referenced path parameter based on the standardized path parameter includes: Check if the reference object corresponding to the standardized path parameter exists in the global path registry. If it exists, use the standardized path parameter as the value in the second JSON key-value pair. Otherwise, the value in the second JSON key-value pair is set to empty.

8. The method according to claim 6, characterized in that, The method further includes: Traverse each configuration node of the DOM tree; If multiple configuration nodes with the same name of reference node type exist under the same parent node, the reference path parameters recorded by each configuration node are converted into normalized path parameters containing indexes, and the normalized path parameters containing indexes are stored in the global path registry.

9. The method according to claim 1, characterized in that, The node type includes object nodes, and the object nodes include module nodes. The method further includes: If the node type of the configuration node is a module node and the module name of the configuration node does not belong to the preset module set, then the configuration node and its child nodes are skipped.

10. An apparatus for converting an ARXML file into a JSON file, characterized in that, The device includes: The file conversion module is used to obtain ARXML files and convert the ARXML files into DOM trees; The node type determination module is used to determine the node type of the current configuration node for each configuration node in the DOM tree; The key-value pair generation module is used to generate JSON key-value pairs corresponding to the configuration node according to the conversion rules corresponding to the node type if the node type is one of the preset node type sets. The key-value pair writing module is used to write the JSON key-value pairs into the corresponding positions in the nested structure of the JSON file according to the hierarchical relationship of the currently configured node in the DOM tree.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method as described in any one of claims 1-9.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, it implements the steps of the method as described in any one of claims 1-9.