Data format conversion method, device and equipment and computer readable storage medium

By acquiring the mapping information of business requirements, and utilizing the mapping relationship, flexible conversion between object-oriented data format and two-dimensional data format is achieved, solving the problems of long development cycle and high cost in existing technologies, and improving the efficiency of data format conversion and structural controllability.

CN115221113BActive Publication Date: 2026-05-26HUAWEI TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2021-05-12
Publication Date
2026-05-26

Smart Images

  • Figure CN115221113B_ABST
    Figure CN115221113B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and computer-readable storage medium for data format conversion. The method includes: an apparatus obtaining source data and mapping information acquired based on business requirements; the apparatus obtaining target data based on the mapping information and the source data, wherein the mapping information includes a mapping relationship, which includes a correspondence between first position information and second position information of at least one data object in the source data; wherein the first position information is the position of at least one data object in the data structure of the source data, the second position information is the position of at least one data object in the data structure of the target data, and the data object at the position corresponding to the second position information includes the data object at the position corresponding to the first position information. This method has high data format conversion efficiency; since the data format conversion is based on the mapping information, the structure of the converted target data is controllable.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims priority to Chinese Patent Application No. 202110423829.2, filed on April 20, 2021, entitled "A Method and Apparatus for Data Acquisition", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of data processing technology, and in particular to methods, apparatus, devices and computer-readable storage media for data format conversion. Background Technology

[0003] With the diversification of data formats, there is often a need for conversion between different data formats. For example, the conversion between two-dimensional data formats and object-oriented data formats.

[0004] In related technologies, a hard-coded conversion method is used to develop and release product versions according to customer requirements. Because this data format conversion method requires release with each product version, it not only has a long development and release cycle but also high customization costs. Summary of the Invention

[0005] This application proposes a data format conversion method, apparatus, device, and computer-readable storage medium to improve the data format conversion efficiency, achieve controllable structure of the converted target data, and is applicable to a wide range of source data structures.

[0006] Firstly, a data format conversion method is provided, comprising: a device obtaining source data and mapping information, the mapping information being obtained based on business requirements; the device obtaining target data based on the mapping information and the source data, the mapping information including a mapping relationship, the mapping relationship including a correspondence between first position information and second position information of at least one data object in the source data; wherein, the first position information is the position of the at least one data object in the data structure of the source data, the second position information is the position of the at least one data object in the data structure of the target data, and the data object at the position corresponding to the second position information includes the data object at the position corresponding to the first position information.

[0007] This method obtains mapping information based on business requirements and then transforms the source data's data structure to obtain the target data, resulting in higher data format conversion efficiency. Secondly, since the data conversion is based on mapping information, which includes the correspondence between the first and second position information of at least one data object in the source data, the structure of the converted target data is controllable. For different source data structures, the format of the converted target data remains the same, making this method applicable to a wide range of source data structures.

[0008] In one possible implementation, the mapping information further includes an information identifier and conversion mode information; the information identifier identifies the mapping information; the conversion mode information indicates the conversion mode, the format of the source data, and the format of the target data, wherein the conversion mode indicates the conversion from the format of the source data to the format of the target data. The mapping information can be quickly obtained through this information identifier.

[0009] In one possible implementation, the source data is in an object-oriented data format, the target data is in a two-dimensional data format, and the mapping information is used to convert the source data in the object-oriented data format into the target data in the two-dimensional data format.

[0010] In one possible implementation, the mapping relationship includes a header column and an attribute path corresponding to the header column, the first location information includes the attribute path, and the second location information includes the header column; the device obtains target data based on the mapping information and the source data, including: the device generates target data based on the header column in the mapping relationship, the attribute path corresponding to the header column, and the source data.

[0011] In one possible implementation, the device generates target data based on the title column in the mapping relationship, the attribute path corresponding to the title column, and the source data, including: the device obtains a first title column from the mapping relationship, generates a first title array based on the first title column, the first title array including the attribute path, an array count value, and the quantity value of the attribute path under the first title array; based on the array count value and the quantity value, it is determined that the attribute path is not the last attribute path under the first title array, and the attribute path corresponding to the first title array obtains a data object from the source data according to the array count value and outputs it as a row of the target data in the two-dimensional data format.

[0012] In one possible implementation, the source data is in a two-dimensional data format, the target data is in an object-oriented data format, and the mapping information is used to convert the source data in the two-dimensional data format into the target data in the object-oriented data format.

[0013] In one possible implementation, the mapping relationship includes a header column and an attribute path corresponding to the header column, the first location information includes the header column, and the second location information includes the attribute path; the device obtains target data based on the mapping information and the source data, including: the device generates target data based on the header column in the mapping relationship, the attribute path corresponding to the header column, and the source data.

[0014] In one possible implementation, the device generates target data based on the header column in the mapping relationship, the attribute path corresponding to the header column, and the source data, including: the device obtains a second header column from the mapping relationship, generates a second header array based on the second header column, the second header array including the attribute path and an array count value; in response to the current row of the source data being less than the total number of rows, the data object indicated by the current row in the source data is filled into the data structure of the target data according to the position specified by the attribute path and the array count value.

[0015] In one possible implementation, the business requirement includes association information for obtaining the mapping information; obtaining the mapping information, which is obtained based on the business requirement, includes: obtaining the mapping information based on the association information in the business requirement. This method of obtaining mapping information through association information offers greater flexibility in how the mapping information is acquired.

[0016] In one possible implementation, the association information includes the information identifier of the mapping information.

[0017] In one possible implementation, obtaining the mapping information, which is acquired based on business requirements, includes: acquiring user-specified mapping information or default mapping information based on the business requirements. The acquired mapping information can also be specified mapping information or default mapping information acquired based on business requirements. This method offers considerable flexibility in acquiring mapping information.

[0018] In one possible implementation, the source data is in JSON format and the target data is in CSV format, or the source data is in CSV format and the target data is in JSON format.

[0019] In one possible implementation, the device type includes at least one of a network management system, a software-defined networking (SDN) controller network element device, a terminal, and a server.

[0020] Furthermore, since the header column in the mapping information is associated with the attribute path, this method enables conversion between object-oriented data format and two-dimensional data format, as well as conversion between two-dimensional data format and object-oriented data format. The data structure conversion process of this method is reversible. During the conversion process from object-oriented data format to two-dimensional data format and back to object-oriented data format, the object-oriented data format remains consistent before and after the conversion.

[0021] Secondly, a data format conversion device is provided, comprising:

[0022] The acquisition module is used to obtain source data and mapping information, wherein the mapping information is obtained based on business requirements;

[0023] A conversion module is used to obtain target data based on the mapping information and the source data. The mapping information includes a mapping relationship, which includes a correspondence between first position information and second position information of at least one data object in the source data. The first position information is the position of the at least one data object in the data structure of the source data, and the second position information is the position of the at least one data object in the data structure of the target data. The data object in the position corresponding to the second position information includes the data object in the position corresponding to the first position information.

[0024] In one possible implementation, the mapping information further includes an information identifier and conversion mode information; the information identifier is used to identify the mapping information; the conversion mode information is used to indicate the conversion mode, the format of the source data, and the format of the target data, wherein the conversion mode is used to indicate the conversion from the format of the source data to the format of the target data.

[0025] In one possible implementation, the source data is in an object-oriented data format, the target data is in a two-dimensional data format, and the mapping information is used to convert the source data in the object-oriented data format into the target data in the two-dimensional data format.

[0026] In one possible implementation, the mapping relationship includes a header column and an attribute path corresponding to the header column, the first location information includes the attribute path, and the second location information includes the header column; the conversion module is used to generate target data based on the header column in the mapping relationship, the attribute path corresponding to the header column, and the source data.

[0027] In one possible implementation, the conversion module is configured to obtain a first header column from the mapping relationship, generate a first header array based on the first header column, the first header array including the attribute path, an array count value, and the quantity value of the attribute path under the first header array; determine that the attribute path is not the last attribute path under the first header array based on the array count value and the quantity value, and obtain data objects from the source data according to the array count value for the attribute path corresponding to the first header array and output them as a row of the target data in the two-dimensional data format.

[0028] In one possible implementation, the source data is in a two-dimensional data format, the target data is in an object-oriented data format, and the mapping information is used to convert the source data in the two-dimensional data format into the target data in the object-oriented data format.

[0029] In one possible implementation, the mapping relationship includes a header column and an attribute path corresponding to the header column, the first location information includes the header column, and the second location information includes the attribute path; the conversion module is used to generate target data based on the header column in the mapping relationship, the attribute path corresponding to the header column, and the source data.

[0030] In one possible implementation, the conversion module is configured to obtain a second header column from the mapping relationship, generate a second header array based on the second header column, the second header array including an attribute path and an array count value; in response to the current row of the source data being less than the total number of rows, fill the data object indicated by the current row in the source data into the data structure of the target data according to the position specified by the attribute path and the array count value.

[0031] In one possible implementation, the business requirement includes association information for obtaining the mapping information; the obtaining module is used to obtain the mapping information based on the association information in the business requirement.

[0032] In one possible implementation, the association information includes the information identifier of the mapping information.

[0033] In one possible implementation, the acquisition module is used to acquire user-specified mapping information or default mapping information based on the business requirements.

[0034] In one possible implementation, the source data is in JSON format and the target data is in CSV format, or the source data is in CSV format and the target data is in JSON format.

[0035] In one possible implementation, the device type includes at least one of a network management system, an SDN controller network element device, a terminal, and a server.

[0036] Thirdly, a data format conversion device is provided, including a processor and a computer program, wherein when the processor executes the computer program, the data format conversion device implements any of the data format conversion methods described in the first aspect above.

[0037] Fourthly, a computer-readable storage medium is provided, on which a computer program is stored, wherein when the computer program is executed by a computer, a data format conversion method as described in the first aspect is implemented.

[0038] Fifthly, a computer program product is provided, including a computer program, which, when executed by a computer, implements a data format conversion method as described in the first aspect above.

[0039] A sixth aspect provides a communication device comprising: a transceiver, a memory, and a processor. The transceiver, the memory, and the processor communicate with each other via an internal connection path. The memory stores instructions, and the processor executes the instructions stored in the memory to control the transceiver to receive and transmit signals. When the processor executes the instructions stored in the memory, it causes the processor to perform the method of the first aspect or any possible implementation thereof.

[0040] As one exemplary embodiment, there are one or more processors and one or more memories.

[0041] As an exemplary embodiment, the memory may be integrated with the processor, or the memory may be disposed separately from the processor.

[0042] In the specific implementation process, the memory can be a memory, such as a read-only memory (ROM), which can be integrated with the processor on the same chip or set on different chips. The embodiments of this application do not limit the type of memory or the way the memory and the processor are set.

[0043] In a seventh aspect, a chip is provided, including a processor for retrieving and executing instructions stored in a memory, causing a communication device on which the chip is mounted to perform the methods described in the first aspect or any possible implementation thereof.

[0044] Eighthly, another chip is provided, comprising: an input interface, an output interface, a processor, and a memory, wherein the input interface, the output interface, the processor, and the memory are connected via an internal connection path, and the processor is used to execute code in the memory. When the code is executed, the processor is used to perform the method described in the first aspect or any possible implementation thereof. Attached Figure Description

[0045] Figure 1 This is a schematic diagram illustrating the implementation environment of a data format conversion method provided in an embodiment of this application;

[0046] Figure 2This is a flowchart of a data format conversion method provided in an embodiment of this application;

[0047] Figure 3 This is a schematic diagram of business planning information provided in an embodiment of this application;

[0048] Figure 4 This is a schematic diagram of a data format conversion interaction process provided in an embodiment of this application;

[0049] Figure 5 This is a schematic diagram of an object-oriented data provided in an embodiment of this application;

[0050] Figure 6 This is a schematic diagram of two-dimensional data provided in an embodiment of this application;

[0051] Figure 7 This is a schematic diagram of a mapping information provided in an embodiment of this application;

[0052] Figure 8 This is a schematic diagram of another mapping information provided in an embodiment of this application;

[0053] Figure 9 This is a schematic diagram of the structure of target data provided in an embodiment of this application;

[0054] Figure 10 This is a schematic diagram of an object-oriented data provided in an embodiment of this application;

[0055] Figure 11 This is a schematic diagram of the structure of a data format conversion device provided in an embodiment of this application;

[0056] Figure 12 This is a schematic diagram of the structure of a data format conversion device provided in an embodiment of this application;

[0057] Figure 13 This is a schematic diagram of the structure of a data format conversion device provided in an embodiment of this application. Detailed Implementation

[0058] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0059] This application provides a data format conversion method, taking the conversion between object-oriented data formats and two-dimensional data formats as an example. The object-oriented data formats include, but are not limited to, JavaScript Object Notation (JSON) and Extensible Markup Language (XML), while the two-dimensional data formats include, but are not limited to, comma-separated values ​​(CSV) and Excel. Taking the conversion between JSON and CSV as an example, the implementation environment of this method can be as follows: Figure 1 The architecture diagram of the JSON and CSV conversion interface is shown below.

[0060] Figure 1 In this context, the Operation Support System (OSS) serves as the operator's operational support system, comprising a service planning system and a resource system. The service planning system plans service requirements, such as outputting data files including service requirements in a two-dimensional data format. The resource system collects network resource information, such as receiving data files including service requirements in a two-dimensional data format. Service applications (APPs) interact with the OSS, receiving the two-dimensional data format files of service requirements from the OSS and outputting object-oriented data format files back to the OSS.

[0061] The business app's application process includes business creation and business export flows. The business creation flow imports files in two-dimensional data format. For example, a user inputs order requirements into the business planning system, which then inputs a two-dimensional data file of those requirements into the business app, allowing the app to import the file. Alternatively, the user can directly interact with the app to import two-dimensional data files. This business creation flow also calls a conversion model, also known as a converter, to transform two-dimensional data formats into object-oriented data formats. The converter reads the corresponding mapping information and parses the two-dimensional data into object-oriented data format. For instance, a business interface might call a converter to parse a two-dimensional data file and then use the mapping information to convert it to JSON format.

[0062] The business export process outputs object-oriented format data, such as JSON data, by calling a converter to transform the object-oriented data into a two-dimensional data format and then passing it to the resource system. Specifically, the converter for two-dimensional and object-oriented data formats receives object-oriented data files and performs controlled conversion between them according to mapping information. Figure 1 In this context, mapping information is used to control the content of the conversion. Specifically, this mapping information is used to convert source data in object-oriented data format into target data in two-dimensional data format, or to convert source data in two-dimensional data format into target data in object-oriented data format.

[0063] Next, with Figure 2 The method flow shown is used as an example to explain the data format conversion process provided in the embodiments of this application. Exemplarily, the method provided in the embodiments of this application can be applied to... Figure 1 The implementation environment shown includes, but is not limited to, steps 201 and 202. The method is performed by a data format conversion device, hereinafter referred to as the device, which may include, but is not limited to, at least one of a network management system, a software-defined network (SDN) controller network element device, a terminal, and a server.

[0064] Step 201: The device obtains source data and mapping information. The mapping information is obtained based on business requirements.

[0065] The source data refers to the data whose format needs to be converted. For example, the source data and business requirements can be user-inputted data; this application embodiment does not limit the method of obtaining the source data and business requirements.

[0066] In one possible implementation, before executing the method provided in this application embodiment, multiple mapping information can be pre-configured, and these multiple mapping information correspond to different business requirements. For example, business requirements may include business planning information. For instance, business planning information such as... Figure 3 As shown, the service planning information includes service name, service type, source site, source network element, source port, destination site, destination network element, destination port, actual bandwidth, customer name, and service remarks. Service requirements include, but are not limited to: service name, service type, source network element, source port, destination network element, and service remarks. Based on these service requirements, mapping information corresponding to those requirements can be configured. For example, multiple mapping information entries can be pre-configured by the user, allowing the device to execute the method provided in this application embodiment based on these multiple mapping information entries. For instance, as... Figure 4The data format conversion interaction process shown involves a user configuring multiple mapping information entries, inputting these mapping information entries, source data, and business requirements into a data format conversion system, which includes the device. The device executes the method provided in this application embodiment based on the mapping information, source data, and business requirements. Optionally, the device stores a conversion model used to obtain target data based on the mapping information and source data. The input to the conversion model includes source data and mapping information, and the output of the conversion model includes the target data after data format conversion.

[0067] For example, when a user inputs the multiple mapping information, source data, and business requirements into a data format conversion system, they can input them directly into the device, or they can input them into other devices within the data format conversion system that can communicate with the device. Therefore, the device can receive mapping information, source data, and business requirements sent by other devices, and then execute the method provided in the embodiments of this application based on the mapping information, source data, and business requirements.

[0068] In one possible implementation, business requirements include, but are not limited to, association information used to obtain mapping information. For example, the mapping information is obtained based on the association information in the business requirements. That is, obtaining the mapping information, which is obtained based on the business requirements, includes: obtaining the mapping information based on the association information in the business requirements. Optionally, the association information includes an information identifier for the mapping information. Depending on the type of information identifier, obtaining the mapping information based on the association information in the business requirements includes, but is not limited to, the following two methods.

[0069] Method 1: Obtain mapping information based on the name of the mapping information in the business requirements.

[0070] When the information identifier type is a name, Method 1 is used to obtain the mapping information. For example, if the name of the mapping information included in the associated information is ABC, then the mapping information with the name ABC is obtained from multiple pre-configured mapping information based on this ABC.

[0071] Method 2: Obtain mapping information based on the mapping information number in the business requirements.

[0072] When the information identifier type is a number, method two is used to obtain the mapping information. In one possible implementation, corresponding to multiple pre-configured mapping information, the user pre-configures a mapping information list. This mapping information list includes multiple pre-configured mapping information and a number corresponding to each mapping information. For example, if the mapping information included in the associated information has the number 1, then the first mapping information in the mapping information list is obtained based on this number.

[0073] In one possible implementation, the mapping information is either user-specified mapping information or default mapping information obtained based on business requirements. That is, obtaining mapping information is based on business requirements, including obtaining user-specified mapping information or default mapping information based on business requirements. For example, for any business requirement to convert data format 1 to data format 2, mapping information 1 is obtained; for any business requirement to convert data format 2 to data format 1, mapping information 2 is obtained.

[0074] For example, as mentioned above, the mapping information includes an information identifier used to identify the mapping information. Secondly, the mapping information also includes conversion mode information, which indicates the conversion mode (transMode), the source data format (objectType), and the target data format (fileType), with the conversion mode indicating the conversion from the source data format to the target data format.

[0075] Step 202: The device obtains the target data based on the mapping information and the source data.

[0076] In one possible implementation, the device performs data format conversion on the source data based on mapping information to obtain the target data. For example, the mapping information includes a mapping relationship, which includes a correspondence between first position information and second position information of at least one data object in the source data. The first position information is the position of at least one data object in the data structure of the source data, and the second position information is the position of at least one data object in the data structure of the target data. The data object at the position corresponding to the second position information includes the data object at the position corresponding to the first position information. Through this mapping relationship, the position mapping of the same data object in different data structures of the source and target data can be realized, thereby enabling the conversion of the same data object between the data formats of the source and target data.

[0077] For example, the source data is in JSON format and the target data is in CSV format, or the source data is in CSV format and the target data is in JSON format. It should be noted that the source and target data formats can also be other data formats that need to be converted; this embodiment does not limit this. For example, the representation of the first location information corresponds to the data format of the source data, and the representation of the second location information corresponds to the data format of the target data. This embodiment uses the representation of location information corresponding to object-oriented data as an attribute path and the representation of location information corresponding to two-dimensional data as a header column as an example. For example, the source data is... Figure 5 The object-oriented data shown is the target data. Figure 6The example shows two-dimensional data. For the data object "branch1", its first position information is Root[index=0]Branch, and its second position information is that the header column is the root node. For example, the source data is... Figure 6 The two-dimensional data shown is the target data. Figure 5 The example shows object-oriented data. For the data object "branch1", the first position information of the data object is that the header column is the root node, and the second position information of the data object is Root[index=0]Branch. For data formats other than object-oriented data or two-dimensional data, the representation of the position information corresponding to the data format can be determined, and the format conversion can be performed using the method provided in the embodiments of this application, which will not be elaborated here.

[0078] Optionally, depending on the format of the source data, the target data can be obtained based on the mapping information and the source data, including but not limited to the following two cases.

[0079] Scenario 1: The source data is in object-oriented format, the target data is in two-dimensional format, the conversion mode indicates the conversion from object-oriented format to two-dimensional format, and the mapping information is used to convert the source data in object-oriented format into the target data in two-dimensional format.

[0080] For scenario one, the mapping relationship includes the title column and the attribute path corresponding to the title column. The first position information includes the attribute path, and the second position information includes the title column. The device obtains the target data based on the mapping information and the source data, including: the device generates the target data based on the title column in the mapping relationship, the attribute path corresponding to the title column, and the source data.

[0081] For example, the device generates target data based on the header column, the attribute path corresponding to the header column, and the source data in the mapping relationship, including: the device obtains a first header column from the mapping relationship; generates a first header array based on the first header column; the first header array includes attribute paths, an array count value (index), and a maximum number of attribute paths under the first header array; determines that the attribute path is not the last attribute path under the first header array based on the array count value and the maximum number of attribute paths; and retrieves data objects from the source data according to the array count value for the attribute paths corresponding to the first header array and outputs them as a row of target data in a two-dimensional data format. For example, if the number of attribute paths in the first header array is 1, then the array count value (index) of that attribute path is 0, and the maximum number of attribute paths under the first header array is 1. If the number of attribute paths in the first header array is 2, then the array count value (index) of one attribute path is 0, the array count value (index) of the other attribute path is 1, and the maximum number of these two attribute paths under the first header array is 2.

[0082] For example, such as Figure 7 The mapping information shown is identified as Mapping Information 1. This mapping information is used to convert source data in object-oriented data format into target data in two-dimensional data format. The conversion mode information included in this mapping information indicates that the conversion mode is from object-oriented data format to two-dimensional data format (JSON-to-CSV), the source data format is JSON, and the target data format is CSV. The title column includes the root node, network branches, network sub-branches, and other branch information; the attribute path (mappingScript) corresponding to the root node includes $Root[*].Branch, the attribute path corresponding to the network branch includes $Root[*].NstBranch[*].Branch, the attribute path corresponding to the network sub-branch includes $Root[*].NstBranch[*].Twig, and the attribute path corresponding to other branch information includes $Root[*].OthNstBranch[*].

[0083] The first header column obtained from the mapping relationship by calling the transformation model includes: root node, network branch, network sub-branch, and other network information. The first header array generated based on this first header column includes: [$Root[index, max].Branch, $Root[index, max].NstBranch[index, max].Branch, $Root[index, max].NstBranch[index, max].Twig, $Root[index, max].OthNstBranch[index, max]]. Where $Root[index, max].Branch, $Root[index, max].NstBranch[index, max].Branch, $Root[index, max].NstBranch[index, max].Twig and $Root[index, max].OthNstBranch[index, max] are array nodes in this first header array. For example, if the first header array includes one such attribute path, and the number of such attribute paths in the first header array is 1, then the first header array may not include the quantity value. That is, if the number of attribute paths in the first heading array is 1, the first heading array includes the attribute paths and the array count value.

[0084] For example, the source data is Figure 5The object-oriented data shown has an attribute path `$Root[*].Branch` with a count of 2 under the first header array, meaning `max` equals 2. For example, the array count is initially 0, i.e., `index = 0`. Therefore, the array node `$Root[index, max].Branch` is `$Root[index = 0, max = 2].Branch`. Thus, the first header array includes: `[$Root[index = 0, max = 2].Branch, $Root[index = 0, max = 2].NstBranch[index = 0, max = 2].Branch, $Root[index = 0, max = 2].NstBranch[index = 0, max = 2].Twig, $Root[index = 0, max = 2].OthNstBranch[index = 0, max = 0]]`. When the array count is initially 0, in response to an array count less than `max - 1`, the attribute path is not the last attribute path under the first header array. The first line of the target data is output as a row of two-dimensional data, which retrieves the data objects corresponding to the attribute paths of the first title array from the source data according to the array count value. Specifically, the first row of the output target data includes: branch1, nbranch1.1, and twig1.1. Here, branch1 is the data object retrieved from the source data for the corresponding array node $Root[index=0, max=2].Branch, meaning branch1 is the data object retrieved from the source data with attribute path $Root[*].Branch at index=1; nbranch1.1 is the data object retrieved from the corresponding array node $Root[index=0, max=2].NstBranch[index=0, max=2].Branch; and twig1.1 is the data object retrieved from the corresponding array node $Root[index=0, max=2].NstBranch[index=0, max=2].Twig. Since the source data does not include the data object corresponding to the array node $Root[index=0, max=2].OthNstBranch[index=0, max=0], the first row of the target data does not include data objects corresponding to other branch information. For example, the target data in the output two-dimensional data format is as follows: Figure 6 As shown.

[0085] In one possible implementation, after retrieving the data objects from the source data according to the array count value of the attribute path corresponding to the first title array and outputting them as a row of target data in two-dimensional data format, the last array count value in the array node that satisfies the array count value being less than max-1 is incremented by 1. The remaining array count values ​​and their corresponding quantity values ​​are then reset. For example, after outputting the first row of target data, the first title array includes: [$Root[index=0, max=2].Branch, $Root[index=0, max=2].NstBranch[index=1, max=2].Branch, $Root[index=0, max=2].NstBranch[index=1, max=2].Twig, $Root[index=0, max=2].OthNstBranch[index=0, max=0]]. Then the second row of the output target data includes: nbranch1.2, twig1.2. Here, `nbranch1.2` is the data object obtained from the corresponding array node `$Root[index=0, max=2].NstBranch[index=1, max=2].Branch`, and `twig1.2` is the data object obtained from the corresponding array node `$Root[index=0, max=2].NstBranch[index=1, max=2].Twig`. Since `branch1` corresponding to array node `$Root[index=0, max=2].Branch` has already been output in the first line, it will not be output again. Because the source data does not include the data object corresponding to array node `$Root[index=0, max=2].OthNstBranch[index=0, max=0]`, the second line of the target data does not include the data objects corresponding to other branch information.

[0086] For example, after outputting the second line of target data, the first header array includes: [$Root[index=1, max=2].Branch, $Root[index=1, max=2].NstBranch[index=0, max=2].Branch, $Root[index=1, max=2].NstBranch[index=0, max=2].Twig, $Root[index=1, max=2].OthNstBranch[index=0, max=3]]. Then the third line of the output target data includes: branch2, nbranch2.1, twig2.1, 1. Here, branch2 is the data object obtained from the corresponding array node $Root[index=1, max=2].Branch, nbranch2.1 is the data object obtained from the corresponding array node $Root[index=1, max=2].NstBranch[index=0, max=2].Branch, twig2.1 is the data object obtained from the corresponding array node $Root[index=1, max=2].NstBranch[index=0, max=2].Twig, and 1 is the data object obtained from the corresponding array node $Root[index=1, max=2].OthNstBranch[index=0, max=3].

[0087] For example, after outputting the third line of target data, the first header array includes: [$Root[index=1, max=2].Branch, $Root[index=1, max=2].NstBranch[index=1, max=2].Branch, $Root[index=1, max=2].NstBranch[index=1, max=2].Twig, $Root[index=1, max=2].OthNstBranch[index=1, max=3]]. Then the fourth line of the output target data includes: nbranch2.2, twig2.2, 2. Wherein, nbranch2.2 is the data object obtained by the corresponding array node $Root[index=1, max=2].NstBranch[index=1, max=2].Branch, twig2.2 is the data object obtained by the corresponding array node $Root[index=1, max=2].NstBranch[index=1, max=2].Twig, and 2 is the data object obtained by the corresponding array node $Root[index=1, max=2].OthNstBranch[index=1, max=3].

[0088] For example, after outputting the fourth line of target data, the first header array includes: [$Root[index=1, max=2].Branch, $Root[index=1, max=2].NstBranch[index=1, max=2].Branch, $Root[index=1, max=2].NstBranch[index=1, max=2].Twig, $Root[index=1, max=2].OthNstBranch[index=2, max=3]]. Then the fifth line of the output target data includes: 3. Here, 3 is the data object obtained from the corresponding array node $Root[index=1, max=2].OthNstBranch[index=2, max=3].

[0089] For example, if all array count values ​​are not less than max-1, then the attribute path is the last attribute path under the first heading array. For example, when it is determined that the attribute path is the last attribute path under the first heading array based on the array count value and the quantity value, the attribute path corresponding to the first heading array is used to retrieve the data object from the source data according to the array count value and output as a row of target data in two-dimensional data format. The data format conversion process ends, and the output of the target data in two-dimensional data format stops.

[0090] Scenario 2: The source data is in two-dimensional format, the target data is in object-oriented format, the conversion mode indicates the conversion from two-dimensional data format to object-oriented data format, and the mapping information is used to convert the source data in two-dimensional data format into the target data in object-oriented data format.

[0091] For scenario two, the mapping relationship includes the title column and the attribute path corresponding to the title column. The first position information includes the title column, and the second position information includes the attribute path. The device obtains the target data based on the mapping information and the source data, including: the device generates the target data based on the title column, the attribute path corresponding to the title column, and the source data in the mapping relationship.

[0092] For example, generating target data based on the header column, the attribute path corresponding to the header column, and the source data in the mapping relationship includes: the device obtaining a second header column from the mapping relationship; generating a second header array based on the second header column; the second header array including the attribute path and an array count value; and, in response to the current row of the source data being less than the total number of rows, filling the data object indicated by the current row in the source data into the data structure of the target data according to the position specified by the attribute path and the array count value. For example, the initial value of the current row is 0.

[0093] For example, such as Figure 8 The mapping information shown is identified as Mapping Information 2. This mapping information is used to convert source data in two-dimensional data format into target data in object-oriented data format. Specifically, the conversion mode information included in this mapping information indicates that the conversion mode is from two-dimensional data format to object-oriented data format (CSV-to-JSON), the source data format is CSV, and the target data format is JSON. It should be noted that because the attribute paths corresponding to the header columns are interconnected, the data structure of the target data can be determined based on the attribute paths corresponding to the header columns.

[0094] exist Figure 8The mapping information shown includes a header column containing the root node, network branches, network sub-branches, and other branch information. The attribute path corresponding to the root node is $Root[*].Branch, the attribute path corresponding to the network branch is $Root[*].NstBranch[*].Branch, the attribute path corresponding to the network sub-branch is $Root[*].NstBranch[*].Twig, and the attribute path corresponding to other branch information is $Root[*].OthNstBranch[*]. The second header column obtained from the mapping relationship by calling the transformation model includes: root node, network branches, network sub-branches, and other network information. The second header array generated based on this second header column includes: [$Root[index].Branch, $Root[index].NstBranch[index].Branch, $Root[index].NstBranch[index].Twig, $Root[index].OthNstBranch[index]].

[0095] Where $Root[index].Branch, $Root[index].NstBranch[index].Branch, $Root[index].NstBranch[index].Twig, and $Root[index].OthNstBranch[index] are array nodes in this second header array. For example, the data structure of the target data determined according to the attribute path corresponding to the header column is as follows: Figure 9 As shown.

[0096] Still with Figure 6 Taking the illustrated two-dimensional data as an example, this two-dimensional data consists of 5 rows of data objects, so the total number of rows in this two-dimensional data is 5. That is, for the first row of the data object in this two-dimensional data, the current row is 0; the array count value is initially 0. Therefore, the second header array includes:

[0097] [$Root[index=0].Branch,

[0098] $Root[index=0].NstBranch[index=0].Branch,

[0099] $Root[index=0].NstBranch[index=0].Twig,

[0100] $Root[index=0].OthNstBranch[index=0]].

[0101] If the current row is 0, in response to the current row being less than the total number of rows, the data object indicated by the current row in the source data will be filled into the target data's data structure according to the attribute path and the position specified by the array count value. That is, as shown... Figure 9 As shown, the data objects branch1, nbranch1.1, and twig1.1 indicated by the current action 0 are filled into the data structure of the target data. Specifically, branch1 is filled according to the array node $Root[index=0].Branch, that is, branch1 is filled according to the position specified by the attribute path $Root[*].Branch and the array count value index=0; nbranch1.1 is filled according to the array node $Root[index=0].NstBranch[index=0].Branch, and twig1.1 is filled according to the array node $Root[index=0].NstBranch[index=0].Twig. Since the data objects indicated by the current action 0 do not include data objects with other branch information objects, the data object filled into the data structure of the target data according to the array node $Root[index=0].OthNstBranch[index=0]] is null. For example, in response to the null data object in the data structure of the target data, the part corresponding to that array node in the data structure of the target data is deleted. For example, as... Figure 10 The data structure of the target data shown does not include the part corresponding to the array node $Root[index=0].OthNstBranch[index=0]].

[0102] In one possible implementation, after filling the data object indicated by the current row in the source data into the data structure of the target data according to the position specified by the attribute path and array count value, the current row is incremented by 1. Furthermore, the second header array also includes a quantity value (max) of the attribute path under the second header array. In response to the data object indicated by the current row in the source data not being empty, the array count value of the last array node that satisfies the condition that the array count value is less than max-1 is incremented by 1, and the other array count values ​​and the quantity value corresponding to the array count value are reset; in response to the data object indicated by the current row in the source data being empty, the array count value remains unchanged. For example, the second header array includes: [$Root[index, max].Branch, $Root[index, max].NstBranch[index, max].Branch, $Root[index, max].NstBranch[index, max].Twig, $Root[index, max].OthNstBranch[index, max]]. Figure 6In the two-dimensional data shown, the attribute path $Root[*].Branch has a quantity of 2 under the second header array, that is, max = 2.

[0103] For example, after filling in the data object indicated by current line 0, the current line 1, and the second header array includes: [$Root[index=1, max=2].Branch, $Root[index=0, max=2].NstBranch[index=1, max=2].Branch, $Root[index=0, max=2].NstBranch[index=1, max=2].Twig, $Root[index=1, max=2].OthNstBranch[index=0, max=3]]. Therefore, the data objects nbranch1.2 and twig1.2 indicated by current line 1 are filled into the data structure of the target data. Specifically, nbranch1.2 is filled according to the array node $Root[index=0, max=2].NstBranch[index=1, max=2].Branch, and twig1.2 is filled according to the array node $Root[index=0, max=2].NstBranch[index=1, max=2].Twig.

[0104] For example, after filling in the data object indicated by current line 1, current line 2, the second header array includes: [$Root[index=1, max=2].Branch, $Root[index=1, max=2].NstBranch[index=0, max=2].Branch, $Root[index=1, max=2].NstBranch[index=0, max=2].Twig, $Root[index=1, max=2].OthNstBranch[index=0, max=3]]. Therefore, the data objects branch2, nbranch2.1, twig2.1, and 1 indicated by current line 2 are filled into the data structure of the target data. In this configuration, branch2 is filled with data according to the array node $Root[index=1, max=2].Branch, nbranch2.1 is filled with data according to the array node $Root[index=1, max=2].NstBranch[index=0, max=2].Branch, twig2.1 is filled with data according to the array node $Root[index=1, max=2].NstBranch[index=0, max=2].Twig, and 1 is filled with data according to the array node $Root[index=1, max=2].OthNstBranch[index=0, max=3].

[0105] For example, after filling in the data object indicated by current line 2, current line 3, the second header array includes: [$Root[index=1, max=2].Branch, $Root[index=1, max=2].NstBranch[index=1, max=2].Branch, $Root[index=1, max=2].NstBranch[index=1, max=2].Twig, $Root[index=1, max=2].OthNstBranch[index=1, max=3]]. Therefore, the data objects nbranch2.2, twig2.2, and 2 indicated by current line 3 are filled into the data structure of the target data. In this context, nbranch2.2 is filled with data according to the array node $Root[index=1, max=2].NstBranch[index=1, max=2].Branch, twig2.2 is filled with data according to the array node $Root[index=1, max=2].NstBranch[index=1, max=2].Twig, and 2 is filled with data according to the array node $Root[index=1, max=2].OthNstBranch[index=1, max=3].

[0106] For example, after filling in the data object indicated by current line 3, the current line 4, and the second header array include: [$Root[index=1, max=2].Branch, $Root[index=1, max=2].NstBranch[index=1, max=2].Branch, $Root[index=1, max=2].NstBranch[index=1, max=2].Twig, $Root[index=1, max=2].OthNstBranch[index=2, max=3]]. Therefore, the data object 3 indicated by current line 4 is filled into the data structure of the target data. Here, 3 is filled according to the array node $Root[index=1, max=2].OthNstBranch[index=2, max=3].

[0107] For example, when the current row of the source data is greater than or equal to the total number of rows, the data format conversion process ends, and the data object indicated by the current row in the source data is no longer filled into the data structure of the target data according to the position specified by the attribute path and array count value.

[0108] This application embodiment obtains target data by transforming the source data based on the mapping information obtained according to business needs and performing data structure transformation on the mapping information. This method has higher data format conversion efficiency.

[0109] Secondly, since the data transformation is based on mapping information, the structure of the transformed target data is controllable. For different source data structures, the format of the transformed target data is the same according to the same mapping information, making this method applicable to a wide range of source data structures.

[0110] Furthermore, since the header column in the mapping information is associated with the attribute path, this method enables conversion between object-oriented data format and two-dimensional data format, as well as conversion between two-dimensional data format and object-oriented data format. The data structure conversion process of this method is reversible. During the conversion process from object-oriented data format to two-dimensional data format and back to object-oriented data format, the object-oriented data format remains consistent before and after the conversion.

[0111] This application also provides a data format conversion device. Figure 11 This is a schematic diagram of the structure of a data format conversion device provided in an embodiment of this application. Based on Figure 11 The following modules are shown. Figure 11 The data format conversion apparatus shown is capable of performing all or part of the operations performed by the data format conversion device. It should be understood that the apparatus may include more additional modules than those shown, or may omit some of the modules shown; this application embodiment does not impose limitations in this regard. Figure 11 As shown, the device includes: an acquisition module 1101 and a conversion module 1102.

[0112] In one possible implementation, the acquisition module 1101 is used to acquire source data and mapping information, wherein the mapping information is obtained based on business requirements; the conversion module 1102 is used to acquire target data based on the mapping information and source data, wherein the mapping information includes a mapping relationship, and the mapping relationship includes the correspondence between the first position information and the second position information of at least one data object in the source data; wherein the first position information is the position of at least one data object in the data structure of the source data, the second position information is the position of at least one data object in the data structure of the target data, and the data object in the position corresponding to the second position information includes the data object in the position corresponding to the first position information.

[0113] In one possible implementation, the mapping information also includes information identifiers and conversion mode information; the information identifiers are used to identify the mapping information; the conversion mode information is used to indicate the conversion mode, the format of the source data, and the format of the target data, and the conversion mode is used to indicate the conversion from the format of the source data to the format of the target data.

[0114] In one possible implementation, the source data is in an object-oriented data format, the target data is in a two-dimensional data format, and the mapping information is used to convert the source data in the object-oriented data format into the target data in the two-dimensional data format.

[0115] In one possible implementation, the mapping relationship includes a header column and an attribute path corresponding to the header column, the first position information includes the attribute path, and the second position information includes the header column; the conversion module 1102 is used to generate target data based on the header column, the attribute path corresponding to the header column, and the source data in the mapping relationship.

[0116] In one possible implementation, the conversion module 1102 is used to obtain the first header column from the mapping relationship, generate a first header array based on the first header column, the first header array includes attribute paths, array count values, and the number of attribute paths under the first header array; based on the array count value and the number of attributes, it is determined that the attribute path is not the last attribute path under the first header array, and the attribute path corresponding to the first header array is used to obtain data objects from the source data according to the array count value and output as a row of target data in two-dimensional data format.

[0117] In one possible implementation, the source data is in a two-dimensional data format, the target data is in an object-oriented data format, and the mapping information is used to convert the source data in the two-dimensional data format into the target data in the object-oriented data format.

[0118] In one possible implementation, the mapping relationship includes a header column and the attribute path corresponding to the header column, the first position information includes the header column, and the second position information includes the attribute path; the conversion module 1102 is used to generate target data based on the header column, the attribute path corresponding to the header column, and the source data in the mapping relationship.

[0119] In one possible implementation, the conversion module 1102 is used to obtain the second header column from the mapping relationship, generate a second header array based on the second header column, the second header array including attribute paths and array count values; in response to the current row of the source data being less than the total number of rows, the data object indicated by the current row in the source data is filled into the data structure of the target data according to the position specified by the attribute path and the array count value.

[0120] In one possible implementation, the business requirements include association information for obtaining mapping information; the acquisition module 1101 is used to obtain mapping information based on the association information in the business requirements.

[0121] In one possible implementation, the associated information includes the information identifier of the mapping information.

[0122] In one possible implementation, the acquisition module 1101 is used to acquire user-specified mapping information or default mapping information based on business requirements.

[0123] In one possible implementation, the source data is in JSON format and the target data is in CSV format, or the source data is in CSV format and the target data is in JSON format.

[0124] In one possible implementation, the device type includes at least one of a network management system, an SDN controller network element device, a terminal, and a server.

[0125] It should be understood that the above Figure 11 The provided device, in implementing its functions, is only illustrated by the division of the above-described functional modules. In practical applications, the functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. Furthermore, the device and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation processes are detailed in the method embodiments, and will not be repeated here.

[0126] See Figure 12 , Figure 12 A schematic diagram of the structure of a data format conversion device 2000 provided in an exemplary embodiment of this application is shown. Figure 12 The data format conversion device 2000 shown is used to perform the above. Figure 2 The operation involved in the data format conversion method shown is illustrated. The data format conversion device 2000 is, for example, a switch, a router, etc., and can be implemented using a general bus architecture.

[0127] like Figure 12 As shown, the data format conversion device 2000 includes at least one processor 2001, a memory 2003, and at least one communication interface 2004.

[0128] Processor 2001 may be, for example, a general-purpose central processing unit (CPU), a digital signal processor (DSP), a network processor (NP), a graphics processing unit (GPU), a neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits for implementing the embodiments of this application. For example, processor 2001 includes application-specific integrated circuits (ASICs), programmable logic devices (PLDs), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. A PLD may be, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof. It can implement or execute the various logic blocks, modules, and circuits described in connection with the embodiments of this invention. The processor may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0129] Optionally, the data format conversion device 2000 also includes a bus. The bus is used to transfer information between the various components of the data format conversion device 2000. The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 12 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0130] Memory 2003 may be, for example, read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions; random access memory (RAM) or other types of dynamic storage devices capable of storing information and instructions; electrically erasable programmable read-only memory (EEPROM); compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.); magnetic disk storage media or other magnetic storage devices; or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. Memory 2003 may exist independently and be connected to processor 2001 via a bus. Memory 2003 may also be integrated with processor 2001.

[0131] The communication interface 2004 uses any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), or Wireless Local Area Network (WLAN). The communication interface 2004 can include wired and wireless communication interfaces. Specifically, the communication interface 2004 can be an Ethernet interface, a Fast Ethernet (FE) interface, a Gigabit Ethernet (GE) interface, an Asynchronous Transfer Mode (ATM) interface, a WLAN interface, a cellular network communication interface, or a combination thereof. The Ethernet interface can be an optical interface, an electrical interface, or a combination thereof. In this embodiment, the communication interface 2004 can be used by the data format conversion device 2000 to communicate with other devices.

[0132] In a specific implementation, as one example, the processor 2001 may include one or more CPUs, such as... Figure 12 The CPU0 and CPU1 shown are examples of processors. Each of these processors can be a single-core processor or a multi-core processor. A processor here can refer to one or more devices, circuits, and / or processing cores used to process data (e.g., computer program instructions).

[0133] In a specific implementation, as one example, the data format conversion device 2000 may include multiple processors, such as... Figure 12 The processors shown are 2001 and 2005. Each of these processors can be a single-core processor or a multi-core processor. Here, "processor" can refer to one or more devices, circuits, and / or processing cores used to process data (such as computer program instructions).

[0134] In a specific implementation, as one example, the data format conversion device 2000 may further include an output device and an input device. The output device communicates with the processor 2001 and can display information in various ways. For example, the output device may be a liquid crystal display (LCD), a light-emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector, etc. The input device communicates with the processor 2001 and can receive user input in various ways. For example, the input device may be a mouse, keyboard, touchscreen device, or sensor device, etc.

[0135] In some embodiments, the memory 2003 stores program code 2010 for executing the solution of this application, and the processor 2001 can execute the program code 2010 stored in the memory 2003. That is, the data format conversion device 2000 can implement the data format conversion method provided in the method embodiment through the processor 2001 and the program code 2010 in the memory 2003. The program code 2010 may include one or more software modules. Optionally, the processor 2001 itself may also store program code or instructions for executing the solution of this application.

[0136] In a specific embodiment, the data format conversion device 2000 of this application embodiment can correspond to the data format conversion device in the above-described data format conversion method embodiments. The processor 2001 in the data format conversion device 2000 reads instructions from the memory 2003, causing... Figure 12 The data format conversion device 2000 shown can perform all or part of the operations performed by the data format conversion device.

[0137] The data format conversion device 2000 can also correspond to the above. Figure 11The data format conversion device shown in the diagram is implemented using software within the data format conversion device 2000. In other words, the functional modules included in the data format conversion device are generated by the processor 2001 of the data format conversion device 2000 reading the program code 2010 stored in the memory 2003.

[0138] in, Figure 2 Each step of the data format conversion method shown is completed by the integrated logic circuitry of the hardware or by software instructions in the processor of the data format conversion device 2000. The steps of the method disclosed in the embodiments of this application can be directly implemented by the hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. Since the storage medium is located in memory, the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method; to avoid repetition, these will not be described in detail here.

[0139] See Figure 13 , Figure 13 A schematic diagram of the structure of a data format conversion device 2100 provided in another exemplary embodiment of this application is shown. Figure 13 The data format conversion device 2100 shown is used to perform the above. Figure 2 The data format conversion method shown involves all or part of the operations. The data format conversion device 2100 is, for example, a switch, a router, etc., and can be implemented using a general bus architecture.

[0140] like Figure 13 As shown, the data format conversion device 2100 includes a main control board 2110 and an interface board 2130.

[0141] The main control board, also known as the main processing unit (MPU) or route processor card, is used to control and manage the various components in the data format conversion device 2100, including routing calculation, device management, device maintenance, and protocol processing functions. The main control board 2110 includes a central processing unit 2111 and a memory 2112.

[0142] Interface board 2130 is also called a line processing unit (LPU), linecard, or service board. Interface board 2130 provides various service interfaces and implements packet forwarding. Service interfaces include, but are not limited to, Ethernet interfaces, POS (packet over SONET / SDH) interfaces, etc., with Ethernet interfaces including, for example, flexible Ethernet clients (FlexE Clients). Interface board 2130 includes: a central processing unit 2131, a network processor 2132, a forwarding table entry memory 2134, and a physical interface card (PIC) 2133.

[0143] The central processing unit 2131 on the interface board 2130 is used to control and manage the interface board 2130 and communicate with the central processing unit 2111 on the main control board 2110.

[0144] Network processor 2132 is used to implement packet forwarding processing. Network processor 2132 can be in the form of a forwarding chip. The forwarding chip can be a network processor (NP). In some embodiments, the forwarding chip can be implemented using an application-specific integrated circuit (ASIC) or a field-programmable gate array (FPGA). Specifically, network processor 2132 forwards received packets based on the forwarding table stored in forwarding table entry memory 2134. If the destination address of the packet is the address of the data format conversion device 2100, the packet is sent to the CPU (such as central processing unit 2131) for processing; if the destination address of the packet is not the address of the data format conversion device 2100, the next hop and outgoing interface corresponding to the destination address are looked up in the forwarding table according to the destination address, and the packet is forwarded to the outgoing interface corresponding to the destination address. Uplink packet processing may include: packet ingress interface processing, forwarding table lookup; downlink packet processing may include: forwarding table lookup, etc. In some embodiments, the central processing unit may also perform the functions of the forwarding chip, such as implementing software forwarding based on a general-purpose CPU, so that the forwarding chip is not required in the interface board.

[0145] The physical interface card 2133 is used to implement physical layer interfacing functions. Raw traffic enters the interface board 2130 through this card, and processed packets are sent out from the physical interface card 2133. The physical interface card 2133, also called a daughter card, can be installed on the interface board 2130. It is responsible for converting photoelectric signals into packets, performing validity checks on the packets, and forwarding them to the network processor 2132 for processing. In some embodiments, the central processing unit 2131 can also perform the functions of the network processor 2132, such as implementing software forwarding based on a general-purpose CPU, thus eliminating the need for the network processor 2132 in the physical interface card 2133.

[0146] Optionally, the data format conversion device 2100 includes multiple interface boards. For example, the data format conversion device 2100 also includes an interface board 2140, which includes a central processing unit 2141, a network processor 2142, a forwarding table entry memory 2144, and a physical interface card 2143. The functions and implementation methods of each component in the interface board 2140 are the same as or similar to those of the interface board 2130, and will not be described in detail here.

[0147] Optionally, the data format conversion device 2100 also includes a switching fabric unit 2120. The switching fabric unit 2120 can also be referred to as a switch fabric unit (SFU). When the data format conversion device has multiple interface boards, the switching fabric unit 2120 is used to complete data exchange between the interface boards. For example, interface boards 2130 and 2140 can communicate via the switching fabric unit 2120.

[0148] The main control board 2110 and the interface boards are coupled. For example, the main control board 2110, interface boards 2130 and 2140, and the switching network board 2120 communicate with each other via a system bus connected to the system backplane. In one possible implementation, an inter-process communication (IPC) channel is established between the main control board 2110 and interface boards 2130 and 2140, and communication between the main control board 2110 and interface boards 2130 and 2140 is achieved through the IPC channel.

[0149] Logically, the data format conversion device 2100 includes a control plane and a forwarding plane. The control plane includes a main control board 2110 and a central processing unit 2111, while the forwarding plane includes various components that perform forwarding, such as a forwarding table entry memory 2134, a physical interface card 2133, and a network processor 2132. The control plane performs functions such as router operation, generating forwarding tables, processing signaling and protocol messages, and configuring and maintaining the status of network devices. The control plane distributes the generated forwarding tables to the forwarding plane. In the forwarding plane, the network processor 2132 forwards messages received by the physical interface card 2133 based on the forwarding tables distributed by the control plane. The forwarding tables distributed by the control plane can be stored in the forwarding table entry memory 2134. In some embodiments, the control plane and the forwarding plane can be completely separated and not on the same network device.

[0150] It's worth noting that a data format conversion device may have one or more main control boards, including a primary and a backup main control board. It may also have one or more interface boards; the more powerful the data processing capability of the data format conversion device, the more interface boards it provides. Each interface board may also have one or more physical interface cards. A switching network board may or may not exist; multiple boards can share the load and provide redundancy. In a centralized forwarding architecture, the data format conversion device may not need a switching network board, as the interface boards handle the entire system's business data processing. In a distributed forwarding architecture, the data format conversion device can have at least one switching network board, enabling data exchange between multiple interface boards and providing high-capacity data exchange and processing capabilities. Therefore, the data access and processing capabilities of a distributed architecture data format conversion device are greater than those of a centralized architecture data format conversion device. Alternatively, the data format conversion device can also be a single board, without a switching network board. The functions of the interface board and the main control board are integrated on this one board. In this case, the central processing unit on the interface board and the central processing unit on the main control board can be combined into a single central processing unit to perform the combined functions. This type of data format conversion device has lower data exchange and processing capabilities (e.g., low-end switches or routers). The specific architecture adopted depends on the specific network deployment scenario, and no restrictions are imposed here.

[0151] In a specific embodiment, the data format conversion device 2100 corresponds to the above-described... Figure 11 The data format conversion device shown. In some embodiments, Figure 11 The acquisition module 1101 in the data format conversion device shown is equivalent to the physical interface card 2133 in the data format conversion device 2100; the conversion module 1102 is equivalent to the central processing unit 2111 or network processor 2132 in the data format conversion device 2100.

[0152] Based on the above Figure 12 and Figure 13 The present application also provides a data format conversion system, comprising a control device and a display interface. Optionally, the control device is... Figure 12 The data format conversion device shown is 2000 or Figure 13 The data format conversion device 2100 shown has the following display interface: Figure 12 The data format conversion device shown is 2000 or Figure 13 The data format conversion device 2100 shown.

[0153] The data format conversion method performed by the data format conversion device can be found above. Figure 2 The relevant descriptions of the embodiments shown will not be repeated here.

[0154] This application also provides a communication device, which includes a transceiver, a memory, and a processor. The transceiver, the memory, and the processor communicate with each other via an internal connection path. The memory stores instructions, and the processor executes the instructions stored in the memory to control the transceiver to receive and transmit signals. Furthermore, when the processor executes the instructions stored in the memory, it causes the processor to perform a data format conversion method required by the control device.

[0155] This application also provides a communication device, which includes a transceiver, a memory, and a processor. The transceiver, the memory, and the processor communicate with each other via an internal connection path. The memory stores instructions, and the processor executes the instructions stored in the memory to control the transceiver to receive and transmit signals. Furthermore, when the processor executes the instructions stored in the memory, it causes the processor to perform a data format conversion method required by the display interface.

[0156] It should be understood that the aforementioned processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors or any conventional processor. It is worth noting that the processor can be a processor supporting the Advanced Reduced Instruction Set Computing (RISC) machine (ARM) architecture.

[0157] Furthermore, in an alternative embodiment, the memory described above may include read-only memory and random access memory, and provide instructions and data to the processor. The memory may also include non-volatile random access memory. For example, the memory may also store device type information.

[0158] The memory can be volatile or non-volatile, or may include both. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which serves as an external cache. Many forms of RAM are available by way of example, but not limitation. Examples include static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).

[0159] This application also provides a computer-readable storage medium storing at least one instruction, which is loaded and executed by a processor to implement the data format conversion method described above.

[0160] This application also provides a computer program (product) that, when executed by a computer, causes the processor or computer to perform the various steps and / or processes of the data format conversion method corresponding to the above method embodiments.

[0161] This application also provides a chip, including a processor, for calling and executing instructions stored in a memory, causing a communication device equipped with the chip to perform the data format conversion methods described above.

[0162] This application embodiment also provides another chip, including: an input interface, an output interface, a processor, and a memory. The input interface, the output interface, the processor, and the memory are connected through an internal connection path. The processor is used to execute code in the memory. When the code is executed, the processor is used to execute the data format conversion method in the above aspects.

[0163] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk).

[0164] Those skilled in the art will recognize that the method steps and modules described in conjunction with the embodiments disclosed herein can be implemented in software, hardware, firmware, or any combination thereof. To clearly illustrate the interchangeability of hardware and software, the steps and components of each embodiment have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0165] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0166] When implemented using software, it can be implemented wholly or partially as a computer program product. This computer program product includes one or more computer program instructions. As an example, the methods of this application embodiment can be described in the context of machine-executable instructions, such as program modules that execute on a device on a real or virtual processor of the target. Generally, program modules include routines, programs, libraries, objects, classes, components, data structures, etc., which perform specific tasks or implement specific abstract data structures. In various embodiments, the functionality of program modules can be combined or divided among the described program modules. The machine-executable instructions for the program modules can execute within a local or distributed device. In a distributed device, the program modules can reside on both local and remote storage media.

[0167] Computer program code used to implement the methods of the embodiments of this application may be written in one or more programming languages. This computer program code may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, such that when executed by the computer or other programmable data processing apparatus, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a computer, partially on a computer, as a standalone software package, partially on a computer and partially on a remote computer, or entirely on a remote computer or server.

[0168] In the context of the embodiments of this application, computer program code or related data may be carried by any suitable carrier to enable a device, apparatus, or processor to perform the various processes and operations described above. Examples of carriers include signals, computer-readable media, etc.

[0169] Examples of signals may include electrical, optical, radio, sound, or other forms of propagation signals, such as carrier waves, infrared signals, etc.

[0170] A machine-readable medium can be any tangible medium that contains or stores programs for or relating to an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. More detailed examples of machine-readable storage media include electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0171] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and modules described above can be found in the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0172] In the embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections through some interfaces, devices, or modules, or they may be electrical, mechanical, or other forms of connection.

[0173] The modules described as separate components may or may not be physically separate. 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 embodiments of this application, depending on actual needs.

[0174] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0175] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0176] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items with substantially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or order of execution. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms. These terms are merely used to distinguish one element from another.

[0177] It should also be understood that, in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0178] In this application, the term "at least one" means one or more, and the term "multiple" means two or more. For example, multiple second messages refer to two or more second messages. The terms "system" and "network" are often used interchangeably in this document.

[0179] It should be understood that the terminology used in the description of the various examples herein is for the purpose of describing particular examples only and is not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise.

[0180] It should also be understood that the term "and / or" as used herein refers to and covers any and all possible combinations of one or more of the associated listed items. The term "and / or" describes an association between related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " in this application generally indicates that the preceding and following related objects are in an "or" relationship.

[0181] It should also be understood that the term “comprising” (also referred to as “includes”, “including”, “comprises” and / or “comprising”) as used in this specification specifies the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0182] It should also be understood that the terms “if” and “if” can be interpreted as meaning “when” or “upon”, or “in response to determination” or “in response to detection”. Similarly, depending on the context, the phrases “if determination…” or “if detection [the stated condition or event]” can be interpreted as meaning “when determination…”, or “in response to determination…”, or “when detection [the stated condition or event]” or “in response to detection [the stated condition or event]”.

[0183] It should be understood that determining B based on A does not mean determining B solely based on A; B can also be determined based on A and / or other information.

[0184] It should also be understood that the phrases "an embodiment," "an embodiment," and "a possible implementation" used throughout the specification mean that a specific feature, structure, or characteristic related to an embodiment or implementation is included in at least one embodiment of this application. Therefore, the phrases "in an embodiment," "an embodiment," or "a possible implementation" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.

[0185] The above description is only an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A data format conversion method, characterized in that, include: The device obtains source data and mapping information. The mapping information is obtained based on business requirements and includes a mapping relationship. The mapping relationship includes the correspondence between the first location information and the second location information of at least one data object in the source data. The first location information is the position of the at least one data object in the data structure of the source data, and the second location information is the position of the at least one data object in the data structure of the target data. The data object in the position corresponding to the second location information includes the data object in the position corresponding to the first location information. The device generates target data based on the title column in the mapping relationship, the attribute path corresponding to the title column, and the source data; wherein, when the source data is in an object-oriented data format, the target data is in a two-dimensional data format, and the mapping information is used to convert the source data in the object-oriented data format into the target data in the two-dimensional data format, the mapping relationship includes the title column and the attribute path corresponding to the title column, the first position information includes the attribute path, and the second position information includes the title column.

2. The method according to claim 1, characterized in that, The mapping information also includes information identifiers and conversion mode information; The information identifier is used to identify the mapping information; The conversion mode information is used to indicate the conversion mode, the format of the source data, and the format of the target data. The conversion mode is used to indicate the conversion from the format of the source data to the format of the target data.

3. The method according to claim 1, characterized in that, When the mapping relationship includes the title column and the attribute path corresponding to the title column, the first location information includes the attribute path, and the second location information includes the title column, the device generates target data based on the title column in the mapping relationship, the attribute path corresponding to the title column, and the source data, including: The device obtains a first title column from the mapping relationship and generates a first title array based on the first title column. The first title array includes the attribute path, an array count value, and the number of attribute paths under the first title array. Based on the array count value and the quantity value, it is determined that the attribute path is not the last attribute path under the first title array. The attribute path corresponding to the first title array is used to obtain the data object from the source data according to the array count value and output as a row of the target data in the two-dimensional data format.

4. The method according to claim 1, characterized in that, When the source data is in a two-dimensional data format and the target data is in an object-oriented data format, and the mapping information is used to convert the source data in the two-dimensional data format into the target data in the object-oriented data format, the mapping relationship includes a header column and an attribute path corresponding to the header column. The first position information includes the header column, and the second position information includes the attribute path.

5. The method according to claim 4, characterized in that, When the mapping relationship includes the title column and the attribute path corresponding to the title column, and the first location information includes the title column and the second location information includes the attribute path, the device generates target data based on the title column in the mapping relationship, the attribute path corresponding to the title column, and the source data, including: The device obtains a second title column from the mapping relationship and generates a second title array based on the second title column. The second title array includes attribute paths and array count values. In response to the current row of the source data being less than the total number of rows, the data object indicated by the current row in the source data is filled into the data structure of the target data according to the attribute path and the position specified by the array count value.

6. The method according to any one of claims 1-5, characterized in that, The business requirements include associated information for obtaining the mapping information; The acquisition of mapping information, which is obtained based on business requirements, includes: acquiring the mapping information based on the association information in the business requirements.

7. The method according to claim 6, characterized in that, The associated information includes the information identifier of the mapping information.

8. The method according to any one of claims 1-5, characterized in that, The acquisition of mapping information, which is obtained based on business requirements, includes: acquiring user-specified mapping information or default mapping information based on the business requirements.

9. The method according to any one of claims 1-5, 7, characterized in that, The source data is in JavaScript Object Notation (JSON) format, and the target data is in comma-separated value CSV format, or... The source data is in CSV format, and the target data is in JSON format.

10. The method according to any one of claims 1-5, 7, characterized in that, The types of devices include at least one of network management systems, software-defined networking (SDN) controller network element devices, terminals, and servers.

11. A data format conversion device, characterized in that, include: Acquisition module and conversion module; The acquisition module is used to obtain source data and mapping information. The mapping information is obtained based on business requirements and includes a mapping relationship. The mapping relationship includes the correspondence between the first position information and the second position information of at least one data object in the source data. The first position information is the position of the at least one data object in the data structure of the source data, and the second position information is the position of the at least one data object in the data structure of the target data. The data object in the position corresponding to the second position information includes the data object in the position corresponding to the first position information. The conversion module is used to generate target data based on the title column in the mapping relationship, the attribute path corresponding to the title column, and the source data; wherein, when the source data is in object-oriented data format, the target data is in two-dimensional data format, and the mapping information is used to convert the source data in object-oriented data format into the target data in two-dimensional data format, the mapping relationship includes the title column and the attribute path corresponding to the title column, the first position information includes the attribute path, and the second position information includes the title column.

12. The apparatus according to claim 11, characterized in that, The mapping information also includes information identifiers and conversion mode information; The information identifier is used to identify the mapping information; The conversion mode information is used to indicate the conversion mode, the format of the source data, and the format of the target data. The conversion mode is used to indicate the conversion from the format of the source data to the format of the target data.

13. The apparatus according to claim 11, characterized in that, In the case where the mapping relationship includes the title column and the attribute path corresponding to the title column, the first position information includes the attribute path, and the second position information includes the title column, the conversion module is configured to obtain the first title column from the mapping relationship, generate a first title array based on the first title column, the first title array including the attribute path, an array count value, and the quantity value of the attribute path under the first title array; determine that the attribute path is not the last attribute path under the first title array based on the array count value and the quantity value, and obtain the data object from the source data according to the array count value for the attribute path corresponding to the first title array and output it as a row of the target data in the two-dimensional data format.

14. The apparatus according to claim 11, characterized in that, When the source data is in a two-dimensional data format and the target data is in an object-oriented data format, and the mapping information is used to convert the source data in the two-dimensional data format into the target data in the object-oriented data format, the mapping relationship includes a header column and an attribute path corresponding to the header column. The first position information includes the header column, and the second position information includes the attribute path.

15. The apparatus according to claim 14, characterized in that, When the mapping relationship includes the title column and the attribute path corresponding to the title column, and the first position information includes the title column and the second position information includes the attribute path, the conversion module is used to obtain the second title column from the mapping relationship, generate a second title array based on the second title column, the second title array including the attribute path and an array count value; in response to the current row of the source data being less than the total number of rows, the data object indicated by the current row in the source data is filled into the data structure of the target data according to the position specified by the attribute path and the array count value.

16. The apparatus according to any one of claims 11-15, characterized in that, The business requirements include associated information for obtaining the mapping information; The acquisition module is used to acquire the mapping information based on the association information in the business requirements.

17. The apparatus according to claim 16, characterized in that, The associated information includes the information identifier of the mapping information.

18. The apparatus according to any one of claims 11-15, characterized in that, The acquisition module is used to acquire user-specified mapping information or default mapping information based on the business requirements.

19. The apparatus according to any one of claims 11-15, 17, characterized in that, The source data is in Javascript Object Notation (JSON) format, and the target data is in comma-separated value (CSV) format; or the source data is in CSV format and the target data is in JSON format.

20. The apparatus according to any one of claims 11-15, 17, characterized in that, The device type includes at least one of network management system, software-defined networking (SDN) controller network element device, terminal and server.

21. A data format conversion device, characterized in that, It includes a processor and a computer program, wherein when the processor executes the computer program, it causes the data format conversion device to implement the data format conversion method according to any one of claims 1-10.

22. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a computer, it implements the data format conversion method according to any one of claims 1-10.

23. A computer program product, characterized in that, It includes a computer program, which, when executed by a computer, implements the data format conversion method according to any one of claims 1-10.