Data processing method and device, electronic equipment and storage medium

By converting JSON files into file organization structures supported by the operating system, editing with file management tools and then converting them back to the original format, the difficulty of editing JSON files in embedded systems is solved, and editing efficiency and data consistency are improved.

CN119248714APending Publication Date: 2025-01-03CHINA AUTOMOTIVE INNOVATION CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411384253.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

In embedded systems with resource-constrained, JSON files are difficult to edit, lack of graphical interfaces and advanced text editing functions, resulting in format mismatch problems, affecting data processing efficiency and consistency.

Method used

By converting JSON files into file organization structures supported by the operating system, editing them using file management tools, and converting them back to the original format after completing the editing, effectively editing the data.

Benefits of technology

It improves the editing efficiency of JSON files in resource-constrained systems, reduces the inconvenience caused by format inadequacy, and ensures data consistency and integrity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248714A_ABST
    Figure CN119248714A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method and device, electronic equipment and a storage medium, the data processing method can be applied to the technical field of data processing, and the method comprises the steps of obtaining a to-be-processed file in response to a first format conversion instruction; the to-be-processed file carries to-be-processed data; based on the data structure of the to-be-processed data, converting the to-be-processed file into a file organization structure to obtain a temporary file; in response to a data editing instruction, editing the to-be-processed data carried by the temporary file based on a file management tool of the current operating system to obtain target data so as to update the temporary file; and in response to a second format conversion instruction, converting the updated temporary file into the data exchange format based on the organization structure of the updated temporary file to obtain a target file, and enabling the target file to carry the target data. According to the method and the device, high efficiency and convenience of data editing in a resource-limited system are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software development technology, and in particular to a data processing method, device, electronic device and storage medium. Background Art

[0002] JSON (JavaScript Object Notation) is a lightweight data exchange format derived from a subset of the ECMAScript standard, which is maintained by the W3C (World Wide Web Consortium) and defines the core syntax of JavaScript. JSON uses a text format that is independent of programming languages ​​to store and represent data, making it an ideal data exchange format across platforms and languages. JSON is known for its concise and clear hierarchical structure, which is not only easy for humans to read and write, but also can effectively improve the efficiency of data transmission across networks.

[0003] With the widespread application of embedded systems, the editing of JSON files has become more and more frequent. In the traditional general operating system environment, users can easily edit JSON files using rich graphical user interface tools or command line tools. However, in resource-constrained embedded systems, the situation is quite different. Such systems usually only provide the most basic command line interface and file system support, lacking graphical interface and advanced text editing functions. Therefore, editing JSON files on such systems requires relying on their basic command line functions and file system operation capabilities, and sometimes even requires installing simple command line programs or executing scripts to achieve basic editing needs for JSON files. Summary of the invention

[0004] In order to solve the problems of the prior art, the embodiments of the present application provide a data processing method, device, electronic device and storage medium. The technical solution is as follows:

[0005] In one aspect, a data processing method is provided, the method comprising:

[0006] In response to the first format conversion instruction, a file to be processed is obtained; the data exchange format of the file to be processed is not compatible with the file management tool of the current operating system; the file to be processed carries the data to be processed;

[0007] Based on the data structure of the data to be processed, the file to be processed is converted into a file organization structure to obtain a temporary file, so that the temporary file carries the data to be processed; the file organization structure is compatible with a file management tool of the current operating system;

[0008] In response to the data editing instruction, the to-be-processed data carried by the temporary file is edited by a file management tool based on the current operating system to obtain target data, so as to update the temporary file, so that the updated temporary file carries the target data;

[0009] In response to the second format conversion instruction, based on the organizational structure of the updated temporary file, the updated temporary file is converted into the data exchange format to obtain a target file, so that the target file carries the target data.

[0010] In another aspect, a data processing device is provided, the device comprising:

[0011] A file acquisition module, configured to acquire a file to be processed in response to a first format conversion instruction; the data exchange format of the file to be processed is incompatible with a file management tool of a current operating system; and the file to be processed carries data to be processed;

[0012] A first format conversion module, configured to convert the to-be-processed file into a file organization structure based on the data structure of the to-be-processed data to obtain a temporary file, so that the temporary file carries the to-be-processed data; the file organization structure is adapted to a file management tool of the current operating system;

[0013] A data editing module, configured to edit the data to be processed carried by the temporary file based on a file management tool of the current operating system in response to a data editing instruction, to obtain target data, so as to update the temporary file, so that the updated temporary file carries the target data;

[0014] The second format conversion module is used to respond to the second format conversion instruction and convert the updated temporary file into the data exchange format based on the organizational structure of the updated temporary file to obtain a target file so that the target file carries the target data.

[0015] In an exemplary embodiment, the first format conversion module includes:

[0016] A first file creation module, used to create a temporary file corresponding to the data to be processed;

[0017] The first file generation module is used to generate a type file corresponding to the data to be processed based on the data type of the data to be processed, and to generate a content file corresponding to the data to be processed based on the data content of the data to be processed, in a temporary file corresponding to the data to be processed, to obtain a temporary file indicating the data to be processed.

[0018] In an exemplary embodiment, the data to be processed includes first type data, and the first type data is composed of attributes and attribute values ​​corresponding to the attributes; the first file generation module includes:

[0019] an attribute file module, configured to generate an attribute file based on the attributes of the data to be processed when the data to be processed is the first type of data;

[0020] A second file creation module, used to create a temporary file corresponding to the attribute value based on the attribute value of the data to be processed;

[0021] The attribute value file module is used to generate a type file corresponding to the attribute value based on the data type of the attribute value, and to generate a content file corresponding to the attribute value based on the data content of the attribute value, so as to obtain a temporary file indicating the attribute value; the attribute file and the temporary file corresponding to the attribute value constitute the content file corresponding to the data to be processed.

[0022] In an exemplary embodiment, the data to be processed includes second type data, and the second type data includes a plurality of ordered elements; the first file generation module includes:

[0023] A third file creation module is used for creating, for each element in the data to be processed, a temporary file corresponding to the element based on the order of the element in the data to be processed when the data to be processed is the second type of data;

[0024] An element file module is used to generate a type file corresponding to the element based on the data type of the element, and to generate a content file corresponding to the element based on the data content of the element, within a temporary file corresponding to the element, to obtain a temporary file indicating the element; the temporary file corresponding to each of the multiple elements constitutes a content file corresponding to the data to be processed.

[0025] In an exemplary embodiment, the data to be processed includes third type data; the device further includes a second file generating module for generating a type file and a content file for the data in the content file in the temporary file when the data indicated by the temporary file is not the third type data, the second file generating module including:

[0026] a type determination module, configured to determine whether the data indicated by the temporary file is the third type of data based on the data type indicated by the type file in the temporary file;

[0027] A third file generation module is used to update the data in the content file of the temporary file to the data to be processed, and update the content file in the temporary file to the temporary file, if the data indicated by the temporary file is not the third type of data, generate a type file and a content file corresponding to the updated data to be processed, obtain a temporary file corresponding to the updated data to be processed, and end the update when the updated data to be processed is the third type of data.

[0028] In an exemplary embodiment, the second format conversion module includes:

[0029] A type determination module, used to determine the data type of the target data based on the type file in the updated temporary file;

[0030] A content determination module, configured to determine the data content of the target data based on the content file in the updated temporary file;

[0031] A structure determination module, configured to determine a target data structure based on a data type of the target data and an organizational structure of the updated temporary file;

[0032] A structure conversion module, used for performing structure conversion on the target data based on the data content of the target data and the structure of the target data;

[0033] A fourth file generating module is used to generate the target file based on the converted target data.

[0034] On the other hand, an electronic device is provided, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement any of the data processing methods described above.

[0035] On the other hand, a computer-readable storage medium is provided, in which at least one instruction or at least one program is stored, and the at least one instruction or the at least one program is loaded and executed by a processor to implement a data processing method as described in any of the above aspects.

[0036] On the other hand, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device performs any of the above-mentioned data processing methods.

[0037] The embodiment of the present application realizes the processing of the data to be processed by converting the to-be-processed file in the data exchange format into a temporary file with a file organization structure, and then using the file management tool of the current operating system to process the temporary file; after the processing is completed, the temporary file is updated, and then the updated temporary file is converted into the data exchange format. Even in a resource-constrained system, effective editing of the data exchange format file can be achieved, thereby improving editing efficiency, reducing the inconvenience caused by format problems, and ensuring the consistency and integrity of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0039] Figure 1 It is a flowchart of a data processing method provided in an embodiment of the present application;

[0040] Figure 2 It is a flowchart of a format conversion instruction execution method provided by an embodiment of the present application;

[0041] Figure 3 It is a schematic diagram of a framework of a file format conversion method provided in an embodiment of the present application;

[0042] Figure 4 It is a flowchart of a file format conversion method provided by an embodiment of the present application;

[0043] Figure 5 It is a schematic diagram of the content of a file to be processed provided by an embodiment of the present application;

[0044] Figure 6 This is a tree structure diagram of a temporary file provided in an embodiment of the present application;

[0045] Figure 7 is a schematic diagram of a tree structure of an updated temporary file provided in an embodiment of the present application;

[0046] Figure 8 It is a schematic diagram of the contents of a target file provided in an embodiment of the present application;

[0047] Fig. 9 is a structural block diagram of a data processing device provided in an embodiment of the present application;

[0048] Fig.10 It is a hardware structure block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0049] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0050] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0051] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0052] See also Figure 1 , which shows a flow chart of a data processing method provided by an embodiment of the present application. It should be noted that this specification provides method operation steps such as the embodiments or flow charts, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiments is only one way of executing the steps among many orders, and does not represent the only order of execution. When the system or product is executed in practice, it can be executed in the order shown in the embodiments or the drawings or in parallel (for example, in a parallel processor or multi-threaded processing environment). Specifically, Figure 1 As shown, the method may include:

[0053] S101, in response to a first format conversion instruction, obtaining a file to be processed.

[0054] The first format conversion instruction indicates that the to-be-processed file is converted from its current data exchange format into a file organization structure. In a specific implementation, the first format conversion instruction is triggered by a user writing an instruction in a command line of the format conversion tool.

[0055] Among them, the data exchange format of the file to be processed is not compatible with the file management tool of the current operating system. Specifically, the user needs to process the file to be processed in the current operating system, and the file management tool of the current operating system does not support directly processing files in the data exchange format.

[0056] Among them, the data exchange format refers to the standard format used to exchange data between different systems, applications or platforms. The data exchange format is usually cross-platform compatible and is designed to facilitate the transmission and parsing of data; the data exchange formats include but are not limited to XML (Extensible Markup Language), JSON, JSON-LD (JSON Linked Data), YAML (YAML Ain't Markup Language), Parquet, Protocol Buffers, ASN.1 (Abstract Syntax Notation One), Thrift, etc. These data exchange formats support common data structures, such as simple values, objects, arrays, etc.

[0057] Taking JSON as an example, assume the name of the format conversion tool is json-dir-tool, and the parameter format of the format conversion tool: json-dir-tool "parameter 1" "parameter 2". If the value of "parameter 1" is "json2dir", it means the command is to convert a JSON file into a file organization structure. At this time, the value of "parameter 2" is the path of the JSON file; after conversion, a folder named "<json file name>.dir" will be generated in the path where the JSON file is located. Then the first format conversion instruction can be示例性 expressed as: json-dir-tool json2dir package.json. Among them, "package.json" is the path of the JSON file to be processed.

[0058] In specific implementation, please refer to Figure 2 , which shows a schematic flowchart of a method for executing a format conversion instruction provided by an embodiment of the present application. If the instruction does not contain parameters, print the command help information and exit; if the first parameter in the instruction is json2dir, execute the first format conversion instruction, and the second parameter in the instruction is the JSON file to be processed.

[0059] Among them, the file management tool refers to the tool for managing and organizing folders and files in the current operating system, which provides a structured method to store, retrieve and manage files in the computer. Specifically, the file management tool uses folders to organize files. Folders can be nested in other folders to form a tree structure. Each file has a unique name in its folder and can be located by a path. The path is a combination of a series of folder names from the root folder to the location of the file. For example, NTFS (New Technology File System) for Windows operating system, HFS+ (Hierarchical File System Plus) for macOS, ext4 (Fourth Extended File System) for Linux operating system, and so on.

[0060] The to-be-processed file carries the to-be-processed data. Specifically, the to-be-processed data may be data of different structures.

[0061] S103, based on the data structure of the data to be processed, convert the file to be processed into a file organization structure to obtain a temporary file, so that the temporary file carries the data to be processed.

[0062] The data structure of the data to be processed refers to the organization and composition of the data to be processed, which defines how the data is stored, organized and accessed. For example, simple values, objects, arrays, etc. have different data structures. Specifically, simple values ​​are usually indivisible data units, and they have no internal structure; objects are a composite data type, which is a collection of key-value pairs, each key is a string, and each value can be any data type (simple value, other object or array); arrays are special objects used to store a series of ordered data items, and each element in the array can be any data type (simple value, object or other array).

[0063] The file organization structure is compatible with the file management tool of the current operating system. Specifically, the file management tool of the current operating system supports files with a direct file organization structure.

[0064] The file organization structure refers to a hierarchical directory structure consisting of folders and files, which is used to organize and manage files in a computer system. This structure usually adopts a tree structure, in which each node represents a folder or file, and the root node is the root directory of the file system.

[0065] For details, please refer to Figure 3, which shows a framework diagram of a file format conversion method provided in an embodiment of the present application. Based on the organization method and composition form of the data to be processed, the data to be processed is represented by a tree structure, and is converted into the form of folders and files based on this, so as to facilitate calling file management tools to edit files or folders.

[0066] The temporary file is used to temporarily store the data to be processed, and is usually deleted after step S107. In specific implementation, the temporary file can be stored in the path where the file to be processed is located, or in the system default path, or in a user-defined path.

[0067] In an exemplary embodiment, Figure 3 As shown, the above step S103 may include:

[0068] S401, creating a temporary file corresponding to the data to be processed.

[0069] In a specific implementation, a new folder can be created under the path where the to-be-processed file is located as a temporary file.

[0070] S403, in a temporary file corresponding to the data to be processed, based on the data type of the data to be processed, generating a type file corresponding to the data to be processed, and based on the data content of the data to be processed, generating a content file corresponding to the data to be processed, to obtain a temporary file indicating the data to be processed.

[0071] The data types of the data to be processed include but are not limited to simple values, objects, arrays, etc.

[0072] The content of the type file is the data type of the data to be processed.

[0073] The content of the content file is the data content of the data to be processed.

[0074] Taking JSON as an example, JSON has three types of data: simple values ​​(numeric values, text, Boolean values, etc.), objects and arrays, and each type of data is mapped to a folder. Specifically, the folder name is the serial number of the JSON simple value data in the upper data set (array or object). The size of the serial number indicates the order of arrangement, and the serial number may not be continuous; the files that can be contained in the folder are: __type, __key, value. Among them, the __type file, that is, the type file is required, and the data type of the JSON data stored in it: integer int, floating point float, string str, Boolean bool, object (dictionary) dict, array list, etc. Among them, the __key file is only valid for object types and is used to store object attributes. For simple values, the value file is required and is used to store JSON simple value data. __key and value belong to content files.

[0075] In an exemplary embodiment, the data to be processed includes first type data, and the first type data is composed of attributes and attribute values ​​corresponding to the attributes; in the above step S403, generating a content file corresponding to the data to be processed based on the data content of the data to be processed may include the following steps:

[0076] In the case where the data to be processed is data of the first type, generating an attribute file based on the attributes of the data to be processed;

[0077] Based on the attribute value of the data to be processed, a temporary file corresponding to the attribute value is created;

[0078] Based on the data type of the attribute value, a type file corresponding to the attribute value is generated, and based on the data content of the attribute value, a content file corresponding to the attribute value is generated to obtain a temporary file indicating the attribute value; the attribute file and the temporary file corresponding to the attribute value constitute the content file corresponding to the data to be processed.

[0079] The first type of data is an object (or dictionary), which is used to store attributes and their corresponding attribute values. Attributes must be immutable types (such as strings, numbers, or tuples), while attribute values ​​can be of any type.

[0080] The content of the attribute file is the attribute value of the data to be processed.

[0081] The content of the type file corresponding to the attribute value is the data type of the attribute value.

[0082] The content of the content file corresponding to the attribute value is the data content of the attribute value.

[0083] For example, see Figure 5 , 6, which respectively show a schematic diagram of the content of a file to be processed provided by an embodiment of the present application, and a schematic diagram of the tree structure of a temporary file provided by an embodiment of the present application. Take the first object as an example of the content of the data to be processed:

[0084] "dependencies":{

[0085] "@go-task / cli":"^3.36.0",

[0086] "@theia / git":"^1.48.3",

[0087] "@theia / task":"^1.48.3",

[0088] "feflow-cli":"^0.15.16",

[0089] "taskbook":"^0.3.0"

[0090] }

[0091] The content of the attribute file _key is dependencies, the content of the type file _type corresponding to the attribute value is dict, and the content file value corresponding to the attribute value includes five folders. In the first folder, the content of the attribute file _key is @go-task / cli, the content of the type file _type corresponding to the attribute value is str, and the content file value corresponding to the attribute value has a content file ^3.36.0.

[0092] It can be seen from the above technical solutions of the embodiment of the present application that the embodiment of the present application converts the data to be processed into a file organization structure through the data structure characteristics of the first type of data, so that each data element corresponds to a file or subdirectory, and the hierarchical structure of files and directories reflects the logical structure of the data, so as to facilitate the use of the file management tool of the current operating system to operate on files / folders to realize the editing function of the files to be processed, reduce the inconvenience caused by format problems, and improve editing efficiency.

[0093] In an exemplary embodiment, the data to be processed includes second type data, and the second type data includes a plurality of ordered elements; in the above step S403, generating a content file corresponding to the data to be processed based on the data content of the data to be processed may include the following steps:

[0094] In the case where the data to be processed is data of the second type, for each element in the data to be processed, based on the order of the elements in the data to be processed, a temporary file corresponding to the element is created;

[0095] In the temporary file corresponding to the element, a type file corresponding to the element is generated based on the data type of the element, and a content file corresponding to the element is generated based on the data content of the element, so as to obtain a temporary file indicating the element; the temporary files corresponding to each element in the multiple elements constitute the content files corresponding to the data to be processed.

[0096] The second type of data is an array, that is, an ordered sequence of elements, and the elements in the array can be of any type.

[0097] Specifically, the name of the temporary file corresponding to the element is the sequence number of the element in the data to be processed. The size of the sequence number indicates the arrangement order, and the sequence numbers may not be continuous.

[0098] The content of the type file corresponding to the element is the data type of the element.

[0099] The content of the content file corresponding to the element is the data content of the element.

[0100] For example, see Figure 5 , 6 , which respectively show a schematic diagram of the content of a file to be processed provided by an embodiment of the present application, and a schematic diagram of the tree structure of a temporary file provided by an embodiment of the present application. Taking the array [22, true, {"k1":"v1"}, 11.2] as an example of the content corresponding to the data to be processed, the content file corresponding to the data to be processed includes four folders, wherein the content of the type file _type corresponding to the first element is int, and the content of the content file value corresponding to the first element is 22.

[0101] It can be seen from the above technical solutions of the embodiment of the present application that the embodiment of the present application converts the data to be processed into a file organization structure through the data structure characteristics of the second type of data, so that each data element corresponds to a file or subdirectory, and the hierarchical structure of files and directories reflects the logical structure of the data, so as to facilitate the use of the file management tool of the current operating system to operate on files / folders to realize the editing function of the files to be processed, reduce the inconvenience caused by format problems, and improve editing efficiency.

[0102] S405: Based on the data type indicated by the type file in the temporary file, determine whether the data indicated by the temporary file is third type data.

[0103] Specifically, if the result of the judgment is no, step S407 can be executed; otherwise, if the result of the judgment is yes, step S409 can be executed.

[0104] Among them, the third type of data is a simple value.

[0105] S407, updating the data in the content file in the temporary file to the data to be processed, and updating the content file in the temporary file to the temporary file.

[0106] Specifically, return to step S403.

[0107] Specifically, when the data indicated by the temporary file is not the third type of data, the data in the content file in the temporary file is updated to the data to be processed, and the content file in the temporary file is updated to the temporary file, and the type file and content file corresponding to the updated data to be processed are generated, and the temporary file corresponding to the updated data to be processed is obtained, until the updated data to be processed is the third type of data, the update is terminated.

[0108] In the specific implementation, the to-be-processed file of the specified path is opened, and its content is read into the memory, the to-be-processed data is parsed from the file, and it is parsed into a memory object (usually a dict or list), and a folder with the same name as the to-be-processed file but with the suffix .dir is created as a temporary file. If the folder already exists, the existing content will not be overwritten or deleted, and a temporary file corresponding to the memory object is generated in the temporary file. If the memory object is a dict or list, the temporary files corresponding to its sub-elements are generated in the same way, and the recursive execution continues until the memory object is no longer a dict or list.

[0109] S409, updating the temporary file created in step S401 to a temporary file, and updating the data in the temporary file to data to be processed.

[0110] Specifically, the temporary file established in step S401 carries the data to be processed in step S101. The temporary file corresponding to the data to be processed in step S101 is used as the current temporary file, and the data in the current temporary file is used as the data to be processed to obtain the temporary file corresponding to the data to be processed, and step S105 is executed based on this.

[0111] It can be seen from the above technical solutions of the embodiment of the present application that the embodiment of the present application converts complex data structures (such as nested dictionaries and lists) into file organization structures so that each data element corresponds to a file or subdirectory. The hierarchical structure of files and directories reflects the logical structure of the data, so that the file management tool of the current operating system can be used to operate files / folders to realize the editing function of the processed files, reduce the inconvenience caused by format problems, improve editing efficiency, and the recursive processing method is applicable to nested data structures of any depth.

[0112] S105, in response to the data editing instruction, the file management tool based on the current operating system edits the data to be processed carried by the temporary file to obtain the target data, so as to update the temporary file, so that the updated temporary file carries the target data.

[0113] The data editing instructions include adding, deleting, modifying and other operations on the data to be processed.

[0114] The target data is the data obtained by executing the data editing instruction on the data to be processed.

[0115] For example, in Windows environment, Figure 6 The package.json.dir folder shown in the figure is modified as follows: If the data editing instruction is rd / s / qpackage.json.dir\90, then delete the package.json.dir\90 folder, that is, delete Figure 5 The / "description":"" entry in package.json is shown; if the data editing instruction is echo 123>package.json.dir\100\__key, the content of the package.json.dir\100\__key file is modified to 123, that is, the / "":"dir" entry in package.json is modified to / "123":"dir"; if the data editing instruction is xcopypackage.json.dir\80\package.json.dir\81\ / s / y / q&&echo license1>package.json.dir\81\__key, the package.json.dir\81 folder is added, that is, the / "license1":"ISC" entry is added to package.json. Based on the above data editing operations, we get Figure 7 The updated temporary file shown.

[0116] S107 , in response to the second format conversion instruction, based on the organizational structure of the updated temporary file, convert the updated temporary file into a data exchange format to obtain a target file, so that the target file carries the target data.

[0117] The second format conversion instruction indicates that the updated temporary file is converted from the file organization structure to a data exchange format, where the data exchange format is consistent with the data exchange format of the to-be-processed file. In a specific implementation, the second format conversion instruction is triggered by a user writing an instruction in the command line of the format conversion tool.

[0118] Taking JSON as an example, assuming that the tool name is json-dir-tool, the parameter format of the format conversion tool is: json-dir-tool "parameter 1" "parameter 2" "parameter 3". If the value of "parameter 1" is "dir2json", it means that the command is to convert the folder of the file organization structure into a JSON file; at this time, the value of "parameter 2" is the path of the folder to be converted, that is, the path of the updated temporary file, and the value of "parameter 3" is the converted JSON file name, that is, the file name of the target file. Then the second format conversion instruction can be exemplarily expressed as: json-dir-tool dir2json package.json.dir new-package.json. Among them, "package.json.dir" is the path of the updated temporary file, and "new-package.json" is the file name of the target file.

[0119] For specific implementation, please refer to Figure 2 , which is a flow chart of a format conversion instruction execution method provided by an embodiment of the present application. If the instruction does not contain parameters, the command help information is printed and the program exits; if the first parameter in the instruction is dir2json, the second format conversion instruction is executed, the second parameter in the instruction is the folder to be converted, and the third parameter is the JSON file name generated by the conversion.

[0120] The organizational structure of temporary files refers to how files and folders are organized and arranged in temporary files. For details, see Figure 3 , the updated temporary file is converted into a data exchange format based on its organizational structure.

[0121] The target file carries the edited data to be processed, namely, the target data.

[0122] It can be seen from the above technical solutions of the embodiment of the present application that the embodiment of the present application realizes the processing of the data to be processed by converting the to-be-processed file in the data exchange format into a temporary file of the file organization structure, and then using the file management tool of the current operating system to process the temporary file; after the processing is completed, the temporary file is updated, and then the updated temporary file is converted into the data exchange format. Even in a resource-constrained system, effective editing of the data exchange format file can be achieved, the editing efficiency is improved, the inconvenience caused by format problems is reduced, and the consistency and integrity of the data are ensured; and the file operation is a basic operation, which reduces the user's learning threshold, and can also be used in a general operating system environment to realize automated editing of files in the data exchange format through command batch scripts.

[0123] In an exemplary embodiment, the above step S107 may include the following steps:

[0124] Determine the data type of the target data based on the type file in the updated temporary file;

[0125] Determine the data content of the target data based on the content file in the updated temporary file;

[0126] Determine the target data structure based on the data type of the target data and the organizational structure of the updated temporary file;

[0127] Based on the data content and structure of the target data, the target data is structurally transformed;

[0128] Generate a target file based on the converted target data.

[0129] The data exchange format of the target file is consistent with the data exchange format of the file to be processed.

[0130] Specifically, read the type file in the temporary file to determine the type of data to be converted. If the type is dict, traverse each subfolder that constitutes the content file in the folder, read the attribute file in each subfolder, and recursively process the subfolders to build a dictionary. If the type is list, traverse each subfolder that constitutes the content file in the folder, recursively process the subfolders, and build a list. If the type is not dict or list, read the simple value in the content file and convert the simple value data according to the type.

[0131] For example, see Figure 7 , 8 , which respectively show a schematic diagram of the tree structure of an updated temporary file provided in an embodiment of the present application, and a schematic diagram of the content of a target file provided in an embodiment of the present application. Taking the content of the type file _type in the package.json.dir folder as dict, it can be seen that the data carried by the package.json.dir folder is an object. The package.json.dir folder includes 10 folders. Each subfolder is traversed and recursively processed to construct an object, and the result is Figure 8 Target data shown.

[0132] It can be seen from the above technical solutions of the embodiment of the present application that after editing the data to be processed carried by the file organization structure, the embodiment of the present application converts the format of the file back to the data exchange format based on the organization structure of the file, thereby completing the effective editing of the file in the data exchange format while ensuring the consistency and integrity of the data.

[0133] Corresponding to the data processing methods provided in the above-mentioned embodiments, an embodiment of the present application also provides a data processing device. Since the data processing device provided in the embodiment of the present application corresponds to the data processing methods provided in the above-mentioned embodiments, the implementation methods of the aforementioned data processing methods are also applicable to the data processing device provided in this embodiment and will not be described in detail in this embodiment.

[0134] See also Fig. 9 , which is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application, the device has the function of implementing the data processing method in the above method embodiment, and the function can be implemented by hardware or by hardware executing corresponding software. Fig. 9 As shown, the device may include:

[0135] The file acquisition module 910 is used to acquire a file to be processed in response to the first format conversion instruction; the data exchange format of the file to be processed is not compatible with the file management tool of the current operating system; the file to be processed carries the data to be processed;

[0136] The first format conversion module 920 is used to convert the to-be-processed file into a file organization structure based on the data structure of the to-be-processed data to obtain a temporary file, so that the temporary file carries the to-be-processed data; the file organization structure is adapted to the file management tool of the current operating system;

[0137] The data editing module 930 is used to edit the data to be processed carried by the temporary file based on the file management tool of the current operating system in response to the data editing instruction to obtain the target data to update the temporary file so that the updated temporary file carries the target data;

[0138] The second format conversion module 940 is used to respond to the second format conversion instruction and convert the updated temporary file into a data exchange format based on the organizational structure of the updated temporary file to obtain a target file so that the target file carries target data.

[0139] In an exemplary embodiment, the first format conversion module includes:

[0140] A first file creation module, used to create a temporary file corresponding to the data to be processed;

[0141] The first file generation module is used to generate a type file corresponding to the data to be processed based on the data type of the data to be processed in the temporary file corresponding to the data to be processed, and to generate a content file corresponding to the data to be processed based on the data content of the data to be processed, so as to obtain a temporary file indicating the data to be processed.

[0142] In an exemplary embodiment, the data to be processed includes first type data, and the first type data is composed of attributes and attribute values ​​corresponding to the attributes; the first file generation module includes:

[0143] The attribute file module is used to generate an attribute file based on the attributes of the data to be processed when the data to be processed is the first type of data;

[0144] A second file creation module, used to create a temporary file corresponding to the attribute value based on the attribute value of the data to be processed;

[0145] The attribute value file module is used to generate a type file corresponding to the attribute value based on the data type of the attribute value, and to generate a content file corresponding to the attribute value based on the data content of the attribute value, so as to obtain a temporary file indicating the attribute value; the attribute file and the temporary file corresponding to the attribute value constitute the content file corresponding to the data to be processed.

[0146] In an exemplary embodiment, the data to be processed includes second type data, and the second type data includes a plurality of ordered elements; the first file generation module includes:

[0147] A third file creation module is used to create a temporary file corresponding to each element in the data to be processed based on the order of the element in the data to be processed when the data to be processed is the second type of data;

[0148] The element file module is used to generate a type file corresponding to the element based on the data type of the element, and to generate a content file corresponding to the element based on the data content of the element, within a temporary file corresponding to the element, to obtain a temporary file indicating the element; the temporary file corresponding to each of the multiple elements constitutes a content file corresponding to the data to be processed.

[0149] In an exemplary embodiment, the data to be processed includes third type data; the apparatus further includes a second file generating module for generating a type file and a content file for the data in the content file in the temporary file when the data indicated by the temporary file is not the third type data, the second file generating module including:

[0150] A type determination module, used for determining whether the data indicated by the temporary file is a third type of data based on the data type indicated by the type file in the temporary file;

[0151] The third file generation module is used to update the data in the content file in the temporary file to the data to be processed, and update the content file in the temporary file to the temporary file, when the data indicated by the temporary file is not the third type of data, generate the type file and content file corresponding to the updated data to be processed, obtain the temporary file corresponding to the updated data to be processed, and end the update when the updated data to be processed is the third type of data.

[0152] In an exemplary embodiment, the second format conversion module includes:

[0153] A type determination module, used for determining the data type of the target data based on the type file in the updated temporary file;

[0154] A content determination module, used to determine the data content of the target data based on the content file in the updated temporary file;

[0155] A structure determination module, used for determining a target data structure based on a data type of the target data and an organizational structure of the updated temporary file;

[0156] A structure conversion module, used for performing structure conversion on target data based on data content and target data structure of the target data;

[0157] The fourth file generating module is used to generate a target file based on the converted target data.

[0158] It should be noted that the device provided in the above embodiment, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0159] An embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement any one of the data processing methods provided in the above method embodiments.

[0160] The memory can be used to store software programs and modules. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, application programs required for functions, etc.; the data storage area can store data created according to the use of the device, etc. In addition, the memory can include a high-speed random access memory and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory can also include a memory controller to provide the processor with access to the memory.

[0161] The method embodiments provided in the embodiments of the present application may be executed in a computer terminal, a server or a similar computing device, that is, the above-mentioned electronic device may include a computer terminal, a server or a similar computing device. Fig.10 is a hardware structure block diagram of a computer device running a data processing method provided by an embodiment of the present invention, such as Fig.10 As shown, the internal structure of the computer device may include but is not limited to: a processor, a network interface and a memory. The processor, network interface and memory in the computer device may be connected via a bus or other means. Fig.10 The example of connecting through bus is taken in the following.

[0162] Among them, the processor (or CPU (Central Processing Unit)) is the computing core and control core of the computer device. The network interface may optionally include a standard wired interface, a wireless interface (such as WI-FI, a mobile communication interface, etc.). Memory is a memory device in a computer device for storing programs and data. It is understandable that the memory here can be a high-speed RAM storage device or a non-volatile memory device (non-volatile memory), such as at least one disk storage device; optionally, it can also be at least one storage device located away from the aforementioned processor. The memory provides a storage space, which stores the operating system of the electronic device, which may include but is not limited to: Windows system (an operating system), Linux (an operating system), Android (Android, a mobile operating system) system, IOS (a mobile operating system) system, etc., and the present invention is not limited to this; and, in the storage space, one or more instructions suitable for being loaded and executed by the processor are also stored, and these instructions may be one or more computer programs (including program codes). In the embodiment of this specification, the processor loads and executes one or more instructions stored in the memory to implement the data processing method provided in the above method embodiment.

[0163] An embodiment of the present application also provides a computer-readable storage medium, which can be set in an electronic device to store at least one instruction or at least one program related to implementing a data processing method. The at least one instruction or the at least one program is loaded and executed by the processor to implement any one of the data processing methods provided in the above method embodiments.

[0164] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.

[0165] It should be noted that the above-mentioned sequence of the embodiments of the present application is for description only and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of this specification are described. Other embodiments are within the scope of the attached claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0166] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0167] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0168] The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A data processing method, characterized in that: The method comprises: In response to the first format conversion instruction, a file to be processed is obtained; the data exchange format of the file to be processed is not compatible with the file management tool of the current operating system; the file to be processed carries the data to be processed; Based on the data structure of the data to be processed, the file to be processed is converted into a file organization structure to obtain a temporary file, so that the temporary file carries the data to be processed; the file organization structure is compatible with a file management tool of the current operating system; In response to the data editing instruction, the to-be-processed data carried by the temporary file is edited by a file management tool based on the current operating system to obtain target data, so as to update the temporary file, so that the updated temporary file carries the target data; In response to the second format conversion instruction, based on the organizational structure of the updated temporary file, the updated temporary file is converted into the data exchange format to obtain a target file, so that the target file carries the target data.

2. The data processing method according to claim 1, characterized in that: The step of converting the file to be processed into a file organization structure based on the data structure of the data to be processed to obtain a temporary file, so that the temporary file carries the data to be processed, includes: Creating a temporary file corresponding to the data to be processed; In a temporary file corresponding to the data to be processed, a type file corresponding to the data to be processed is generated based on the data type of the data to be processed, and a content file corresponding to the data to be processed is generated based on the data content of the data to be processed, so as to obtain a temporary file indicating the data to be processed.

3. The data processing method according to claim 2, characterized in that: The data to be processed includes first type data, and the first type data is composed of attributes and attribute values ​​corresponding to the attributes; generating a content file corresponding to the data to be processed based on the data content of the data to be processed includes: In a case where the data to be processed is the first type of data, generating an attribute file based on the attributes of the data to be processed; Based on the attribute value of the data to be processed, a temporary file corresponding to the attribute value is created; Based on the data type of the attribute value, a type file corresponding to the attribute value is generated, and based on the data content of the attribute value, a content file corresponding to the attribute value is generated to obtain a temporary file indicating the attribute value; the attribute file and the temporary file corresponding to the attribute value constitute the content file corresponding to the data to be processed.

4. The data processing method according to claim 2, characterized in that: The data to be processed includes second type data, and the second type data includes a plurality of ordered elements; The step of generating a content file corresponding to the data to be processed based on the data content of the data to be processed includes: In a case where the data to be processed is the second type of data, for each element in the data to be processed, based on the order of the element in the data to be processed, creating a temporary file corresponding to the element; In the temporary file corresponding to the element, a type file corresponding to the element is generated based on the data type of the element, and a content file corresponding to the element is generated based on the data content of the element, so as to obtain a temporary file indicating the element; the temporary file corresponding to each of the multiple elements constitutes the content file corresponding to the data to be processed.

5. The data processing method according to any one of claims 2 to 4, characterized in that: The data to be processed includes third type data; and the method further includes: Based on the data type indicated by the type file in the temporary file, determining whether the data indicated by the temporary file is the third type of data; In the case where the data indicated by the temporary file is not the third type of data, the data in the content file in the temporary file is updated to the data to be processed, and the content file in the temporary file is updated to the temporary file, and the type file and content file corresponding to the updated data to be processed are generated, and a temporary file indicating the updated data to be processed is obtained, until the updated data to be processed is the third type of data, the update is terminated.

6. The data processing method according to claim 2, characterized in that: The step of converting the updated temporary file into the data exchange format based on the organizational structure of the updated temporary file to obtain a target file so that the target file carries the target data includes: Determine the data type of the target data based on the type file in the updated temporary file; Determine the data content of the target data based on the content file in the updated temporary file; Determine a target data structure based on the data type of the target data and the organizational structure of the updated temporary file; Based on the data content of the target data and the structure of the target data, performing structural conversion on the target data; The target file is generated based on the converted target data.

7. A data processing device, characterized in that: The device comprises: A file acquisition module, configured to acquire a file to be processed in response to a first format conversion instruction; the data exchange format of the file to be processed is incompatible with a file management tool of a current operating system; and the file to be processed carries data to be processed; A first format conversion module, configured to convert the to-be-processed file into a file organization structure based on the data structure of the to-be-processed data to obtain a temporary file, so that the temporary file carries the to-be-processed data; the file organization structure is adapted to a file management tool of the current operating system; A data editing module, configured to edit the data to be processed carried by the temporary file based on a file management tool of the current operating system in response to a data editing instruction, to obtain target data, so as to update the temporary file, so that the updated temporary file carries the target data; The second format conversion module is used to respond to the second format conversion instruction and convert the updated temporary file into the data exchange format based on the organizational structure of the updated temporary file to obtain a target file so that the target file carries the target data.

8. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the data processing method according to any one of claims 1 to 6.

9. A computer-readable storage medium, wherein at least one instruction or at least one program is stored in the storage medium, and the at least one instruction or the at least one program is loaded and executed by a processor to implement the data processing method according to any one of claims 1 to 6.

10. A computer program, characterized in that When the computer program is executed by a processor, the data processing method according to any one of claims 1 to 6 is implemented.