Method and device for generating JSON file of vehicle data
By collecting, assembling, checking and converting vehicle data, generating and encrypting JSON files, the cumbersome problems of vehicle data configuration and analysis processes in the prior art are solved, and more flexible and accurate data management is achieved.
Patent Information
- Application Number
- CN202410707920.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-06-03
AI Technical Summary
In the prior art, the configuration and analysis process of vehicle data is complicated, errors are prone to occur, and is not flexible enough.
By collecting vehicle operation data in real time, assemble data according to the data acquisition format file, perform field verification, data range verification, and data length verification, converting it into a JSON file, and formatting and encrypting the JSON file.
Simplifies the configuration and parsing process of vehicle data, reduces the possibility of errors, and improves process flexibility.
Smart Images

Figure CN118519977B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of automobile data collection, and in particular to a method and device for generating a JSON file of vehicle data. Background Art
[0002] With the continuous development of Internet of Vehicles technology, vehicle information management systems have become an important part of the modern automotive industry. After collecting vehicle data, in order to achieve effective management and monitoring of vehicle data, the vehicle data needs to be configured and parsed. However, the existing vehicle information management system has certain limitations in data configuration and parsing. Traditional data configuration and parsing solutions often use tables or other formats of files for data configuration, and then perform data parsing by manual parsing or writing programs. The limitation of this solution is that the data configuration and parsing process is cumbersome, prone to errors, and not flexible enough. Summary of the invention
[0003] In view of this, an embodiment of the present application provides a method, device, electronic device and storage medium for generating a JSON file of vehicle data to solve the problem that the configuration and parsing process of vehicle data in the prior art is cumbersome, prone to errors, and not flexible enough.
[0004] In a first aspect of an embodiment of the present application, a method for generating a JSON file of vehicle data is provided, comprising: collecting vehicle operation data in real time; assembling the operation data according to a data collection format file to obtain format data; performing field verification, data range verification, and data length verification on the format data; if all verifications pass, converting the format data into a JSON file according to the JSON file format; formatting the JSON file to delete useless information in the JSON file; encrypting identification numbers and / or numerical values in the JSON file to obtain an encrypted JSON file.
[0005] According to a second aspect of an embodiment of the present application, a device for generating a JSON file of vehicle data is provided, comprising: a collection module configured to collect vehicle operation data in real time; an assembly module configured to assemble the operation data according to a data collection format file to obtain format data; a verification module configured to perform field verification, data range verification and data length verification on the format data respectively; a conversion module configured to convert the format data into a JSON file according to the JSON file format when all verifications pass; a formatting module configured to format the JSON file to delete useless information in the JSON file; an encryption module configured to encrypt identification numbers and / or numerical values in the JSON file to obtain an encrypted JSON file.
[0006] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0007] In a fourth aspect of the embodiments of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the methods described above are implemented.
[0008] Compared with the prior art, the beneficial effects of the embodiments of the present application include at least: assembling the vehicle's operating data according to the data acquisition format file to obtain format data, converting the format data into a JSON file when multiple checks on the format data are passed, formatting the JSON file, and encrypting the identification number and / or value in the JSON file. Because JSON files have the advantages of being lightweight, easy to read, and flexible in vehicle information management and monitoring, the above-mentioned technical means can solve the problems in the prior art that the process of vehicle data configuration and parsing is cumbersome, prone to errors, and not flexible enough, thereby providing a simplified process for vehicle data configuration and parsing, reducing errors and improving flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art 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 paying any creative work.
[0010] Figure 1 It is a flowchart of a method for generating a JSON file of vehicle data provided by an embodiment of the present application;
[0011] Figure 2 It is a flowchart of another method for generating a JSON file of vehicle data provided by an embodiment of the present application;
[0012] Figure 3 It is a structural diagram of a device for generating a JSON file of vehicle data provided by an embodiment of the present application;
[0013] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0014] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0015] Figure 1 It is a flowchart of a method for generating a JSON file of vehicle data provided in an embodiment of the present application. Figure 1 The method for generating a JSON file of vehicle data can be executed by a vehicle control system set on the target vehicle, or by a computer or server, or a processor set on a computer or server, or software on a computer or ordinary server. The method for generating a JSON file of vehicle data includes:
[0016] S101, collecting vehicle operation data in real time;
[0017] S102, assembling the operation data according to the data collection format file to obtain format data;
[0018] S103, performing field verification, data range verification and data length verification on the format data respectively;
[0019] S104, if all checks are passed, converting the format data into a JSON file according to the JSON file format;
[0020] S105, formatting the JSON file to delete useless information in the JSON file;
[0021] S106, encrypting the identification number and / or the numerical value in the JSON file to obtain an encrypted JSON file.
[0022] The vehicle's operating data is collected in real time through sensors installed on the vehicle. The vehicle's operating data contains multiple messages, such as speed, mileage, engine status, fuel level, etc. The data acquisition format file specifies the identification number, name, Chinese description, level, data type, precision, signal range, offset, and data recording method (regular period / event) of each message. The Chinese description is used to describe the function of the message. For example, the Chinese description of the speed message is used to indicate the speed of the vehicle. The level includes privacy level, risk level, and message priority. Assembling the operating data according to the data acquisition format file is to add a message header to each message according to the data acquisition format file, obtain the data corresponding to each message, and then obtain the format data. The message header can include the identification number, name, Chinese description, level, data type, precision, signal range, offset, and data recording method (regular period / event) of each message.
[0023] Perform field verification, data range verification, and data length verification on each piece of data in the format data. Delete the data that has not passed all the verifications, and convert the data that has passed all the verifications into JSON objects according to the JSON file format to obtain a JSON file. A JSON file is composed of JSON objects. Formatting a JSON file is to delete useless information in the JSON file, including spaces and comment information, which is information that explains the data. Encrypt the identification number and / or value in the JSON file to obtain an encrypted JSON file.
[0024] According to the technical solution provided in the embodiment of the present application, the operation data of the vehicle is collected in real time; the operation data is assembled according to the data collection format file to obtain the format data; the format data is respectively subjected to field verification, data range verification and data length verification; when all the verifications are passed, the format data is converted into a JSON file according to the JSON file format; the JSON file is formatted to delete useless information in the JSON file; the identification number and / or value in the JSON file is encrypted to obtain an encrypted JSON file. JSON (JavaScript Object Notation) files have the advantages of being lightweight, easy to read, easy to parse, cross-platform, flexible, scalable, secure and compatible with Web technologies in vehicle information management and monitoring. The above-mentioned technical means can solve the problems in the prior art that the configuration and parsing process of vehicle data is cumbersome, prone to errors and not flexible enough, thereby providing a simplified process for the configuration and parsing of vehicle data, reducing errors and improving flexibility.
[0025] Furthermore, the identification numbers and / or values in the JSON file are encrypted to obtain an encrypted JSON file, including: performing the following operations on the identification numbers and / or values in the JSON file in sequence: replacing each byte in the identification numbers and / or values in the JSON file with a byte obtained through an S-Box lookup table; performing a circular right shift operation on the rows in the identification numbers and / or values in the JSON file; performing a mixing operation on the columns in the identification numbers and / or values in the JSON file; and performing a bitwise XOR operation on the identification numbers and / or values in the JSON file using a key to obtain an encrypted JSON file.
[0026] The format data includes the data corresponding to each message, and the data corresponding to each message consists of the message header and the message. The message header contains the identification number of the message, and the value is mainly the message, such as the vehicle speed message is expressed in the form of a value.
[0027] S-Box (Substitution Box) is an important concept in cryptography, especially in block ciphers such as AES (Advanced Encryption Standard). S-Box is a subkey substitution table, which is a mapping from plaintext characters (identifiers and / or values) to ciphertext characters (bytes obtained from the S-Box lookup table).
[0028] The circular right shift operation is performed on the rows of the identification numbers and / or values in the JSON file, which is to shift the identification numbers and / or values right by a few characters according to the rows, for example, the last character becomes the first character, the first character becomes the second character, and so on.
[0029] The "mixing operation" (often called obfuscation or S-box replacement) is one of the key steps to ensure that the data is fully obfuscated during the encryption process. The mixing operation is performed on the columns of identifiers and / or values in the JSON file, which is to replace the identifiers and / or values by bytes on a column-by-column basis.
[0030] In an optional embodiment, decrypting an encrypted JSON file includes: performing the following operations on the identification numbers and / or values in the encrypted JSON file in sequence: performing a bitwise XOR operation on the identification numbers and / or values in the encrypted JSON file using a key; performing an inverse mixing operation on the columns in the identification numbers and / or values in the JSON file, wherein the inverse mixing operation is an inverse operation of the mixing operation; performing a circular left shift operation on the rows in the identification numbers and / or values in the JSON file; and replacing each byte in the identification numbers and / or values in the JSON file with the original byte according to an S-Box lookup table.
[0031] Furthermore, a field check is performed on the formatted data, including: determining whether there is a required field in the message header of each data in the formatted data and whether the data corresponding to the required field is within a first preset range; if there is a required field and the data corresponding to the required field is within the first preset range, determining that the field check has passed, otherwise determining that the field check has failed.
[0032] If a piece of data has a required field and the data corresponding to the required field is within the first preset range, it is determined that the field check of the data has passed, otherwise it is determined that the field check of the data has failed. The required fields may include the vehicle's software version number, vehicle model, controller mode (the controller mode includes the controller big-endian mode and the controller little-endian mode), identification number, Chinese description, data type and message priority, etc. If a piece of data has a required field that does not exist or the data corresponding to the required field is within the first preset range, it is determined that the field check of the data has failed. For example, the first preset range of data types includes eight types: 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int8_t', 'int16_t', 'int32_t', and 'int64_t'. If the data type of a piece of data does not belong to one of the above, the field check of the data has failed. The first preset range of message priorities includes five types: 'INFO', 'WARNING', 'ERROR', 'CRITICAL', and 'DEBUG'. If the message priority of a piece of data does not belong to one of the above types, the field check of the piece of data fails.
[0033] Furthermore, a data range check is performed on the formatted data, including: determining a second preset range of a numerical value in each piece of data based on an identification number in a message header of the formatted data; judging whether the numerical value in each piece of data is within its corresponding second preset range; if so, determining that the data range check has passed, otherwise determining that the data range check has failed.
[0034] If the value in a piece of data is within the corresponding second preset range, the data range check of the piece of data is determined to have passed, otherwise the data range check of the piece of data is determined to have failed. The values in different data have their own ranges, and if they are not within the range, the data range check fails.
[0035] Furthermore, a data length check is performed on the format data, including: determining a preset length of each piece of data based on an identification number in a message header of the format data; judging whether the data length of each piece of data is the same as the preset length; if they are the same, determining that the data length check has passed, otherwise determining that the data length check has failed.
[0036] If the data length of a piece of data is the same as the preset length, it is determined that the data length check of the piece of data passes, otherwise it is determined that the data length check of the piece of data fails.
[0037] If a piece of data fails any of the checks, it will be deleted.
[0038] Furthermore, the operation data is assembled according to the data collection format file to obtain format data, including: the operation data contains multiple messages, and the format data contains data corresponding to each message; the identification number, name, Chinese description and level of each message are determined according to the data collection format file; the message header of each message is assembled based on the identification number, name, Chinese description and level of each message; the message header of each message is spliced together with the message to obtain the data corresponding to each message.
[0039] The data collection format file specifies the identification number, name, Chinese description, level and other information of different types of messages. The message header of each message can be assembled according to the information specified in the data collection format file. The message header of each message is spliced together with the message to obtain the data corresponding to each message.
[0040] Figure 2 FIG. 1 is a flow chart of another method for generating a JSON file of vehicle data provided by an embodiment of the present application. Figure 2 As shown, including:
[0041] Execute the following loop:
[0042] S201, determining whether i is greater than N, where i is the sequence number of the data in the format data, N is the number of all data in the format data, and the initial value of i is 1;
[0043] S202, when i is less than or equal to N, performing field check, data range check and data length check on the i-th data;
[0044] S203, when the i-th data passes all the checks, convert the i-th data into the i-th JSON object according to the JSON file format, add the i-th JSON object to the target file, and update i with the value of i plus 1, wherein the target file is newly created when the first JSON object is obtained;
[0045] S204, when at least one check of the i-th data fails, delete the i-th data and update i with a value i plus 1;
[0046] S205, when i is greater than N, the target file is taken as a JSON file and the loop is exited.
[0047] There are a total of N data in the format data. Field verification, data range verification and data length verification are performed on each data in sequence according to the sequence number. When each data passes all the verifications, each data is converted into a JSON object according to the JSON file format, and finally a JSON file consisting of multiple JSON objects is obtained. If a data fails one verification, it is determined that the data is unqualified and can be deleted. The target file contains the first JSON object, the second JSON object...the i-th JSON object. When i is greater than N, it means that all data are converted into JSON objects. The target file contains all JSON objects. At this time, the target file is used as a JSON file and the loop is exited.
[0048] In one embodiment, the side door control enhanced service reporting event block may be parsed into the following JSON object:
[0049]
[0050]
[0051] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0052] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0053] Figure 3 Schematic diagram of a device for generating a JSON file of vehicle data provided by an embodiment of the present application. Figure 3 As shown, the device for generating a JSON file of vehicle data includes:
[0054] The collection module 301 is configured to collect the operation data of the vehicle in real time;
[0055] An assembling module 302 is configured to assemble the operation data according to the data acquisition format file to obtain format data;
[0056] The verification module 303 is configured to perform field verification, data range verification and data length verification on the format data respectively;
[0057] The conversion module 304 is configured to convert the format data into a JSON file according to the JSON file format when all checks are passed;
[0058] The formatting module 305 is configured to perform a formatting operation on the JSON file to delete useless information in the JSON file;
[0059] The encryption module 306 is configured to encrypt the identification number and / or the value in the JSON file to obtain an encrypted JSON file.
[0060] According to the technical solution provided in the embodiment of the present application, the operation data of the vehicle is collected in real time; the operation data is assembled according to the data collection format file to obtain the format data; the format data is respectively subjected to field verification, data range verification and data length verification; when all the verifications are passed, the format data is converted into a JSON file according to the JSON file format; the JSON file is formatted to delete useless information in the JSON file; the identification number and / or value in the JSON file is encrypted to obtain an encrypted JSON file. JSON (JavaScript Object Notation) files have the advantages of being lightweight, easy to read, easy to parse, cross-platform, flexible, scalable, secure and compatible with Web technologies in vehicle information management and monitoring. The above-mentioned technical means can solve the problems in the prior art that the configuration and parsing process of vehicle data is cumbersome, prone to errors and not flexible enough, thereby providing a simplified process for the configuration and parsing of vehicle data, reducing errors and improving flexibility.
[0061] In some embodiments, the encryption module 306 is also configured to perform the following operations on the identification numbers and / or values in the JSON file in sequence: replace each byte in the identification numbers and / or values in the JSON file with the byte obtained through the S-Box lookup table; perform a circular right shift operation on the rows in the identification numbers and / or values in the JSON file; perform a mixing operation on the columns in the identification numbers and / or values in the JSON file; and perform a bitwise XOR operation on the identification numbers and / or values in the JSON file using the key to obtain an encrypted JSON file.
[0062] The format data includes the data corresponding to each message, and the data corresponding to each message consists of the message header and the message. The message header contains the identification number of the message, and the value is mainly the message, such as the vehicle speed message is expressed in the form of a value.
[0063] S-Box (Substitution Box) is an important concept in cryptography, especially in block ciphers such as AES (Advanced Encryption Standard). S-Box is a subkey substitution table, which is a mapping from plaintext characters (identifiers and / or values) to ciphertext characters (bytes obtained from the S-Box lookup table).
[0064] The circular right shift operation is performed on the rows of the identification numbers and / or values in the JSON file, which is to shift the identification numbers and / or values right by a few characters according to the rows, for example, the last character becomes the first character, the first character becomes the second character, and so on.
[0065] The "mixing operation" (often called obfuscation or S-box replacement) is one of the key steps to ensure that the data is fully obfuscated during the encryption process. The mixing operation is performed on the columns of identifiers and / or values in the JSON file, which is to replace the identifiers and / or values by bytes on a column-by-column basis.
[0066] In some embodiments, the encryption module 306 is also configured to perform the following operations on the identification numbers and / or numerical values in the encrypted JSON file in sequence: perform a bitwise XOR operation on the identification numbers and / or numerical values in the encrypted JSON file using a key; perform an inverse mixing operation on the columns in the identification numbers and / or numerical values in the JSON file, wherein the inverse mixing operation is the inverse operation of the mixing operation; perform a circular left shift operation on the rows in the identification numbers and / or numerical values in the JSON file; and replace each byte in the identification numbers and / or numerical values in the JSON file with the original byte according to the S-Box lookup table.
[0067] In some embodiments, the verification module 303 is also configured to determine whether there is a required field in the message header of each data in the format data and whether the data corresponding to the required field is within a first preset range; if there is a required field and the data corresponding to the required field is within the first preset range, it is determined that the field check passes, otherwise it is determined that the field check fails.
[0068] If a piece of data has a required field and the data corresponding to the required field is within the first preset range, it is determined that the field check of the data has passed, otherwise it is determined that the field check of the data has failed. The required fields may include the vehicle's software version number, vehicle model, controller mode (the controller mode includes the controller big-endian mode and the controller little-endian mode), identification number, Chinese description, data type and message priority, etc. If a piece of data has a required field that does not exist or the data corresponding to the required field is within the first preset range, it is determined that the field check of the data has failed. For example, the first preset range of data types includes eight types: 'uint8_t', 'uint16_t', 'uint32_t', 'uint64_t', 'int8_t', 'int16_t', 'int32_t', and 'int64_t'. If the data type of a piece of data does not belong to one of the above, the field check of the data has failed. The first preset range of message priorities includes five types: 'INFO', 'WARNING', 'ERROR', 'CRITICAL', and 'DEBUG'. If the message priority of a piece of data does not belong to one of the above types, the field check of the piece of data fails.
[0069] In some embodiments, the verification module 303 is also configured to determine a second preset range of numerical values in each piece of data in the formatted data based on an identification number in a message header of the data; determine whether the numerical value in each piece of data is within its corresponding second preset range; if so, determine that the data range check has passed, otherwise determine that the data range check has failed.
[0070] If the value in a piece of data is within the corresponding second preset range, the data range check of the piece of data is determined to have passed, otherwise the data range check of the piece of data is determined to have failed. The values in different data have their own ranges, and if they are not within the range, the data range check fails.
[0071] In some embodiments, the verification module 303 is also configured to determine the preset length of each data in the format data based on the identification number in the message header of the data; determine whether the data length of each data is the same as the preset length; if they are the same, determine that the data length check passes, otherwise determine that the data length check fails.
[0072] If the data length of a piece of data is the same as the preset length, it is determined that the data length check of the piece of data passes, otherwise it is determined that the data length check of the piece of data fails.
[0073] If a piece of data fails any of the checks, it will be deleted.
[0074] In some embodiments, the assembly module 302 is also configured to include multiple messages in the running data, and the format data includes data corresponding to each message; determine the identification number, name, Chinese description and level of each message according to the data acquisition format file; assemble the message header of each message based on the identification number, name, Chinese description and level of each message; splice the message header of each message with the message to obtain the data corresponding to each message.
[0075] The data collection format file specifies the identification number, name, Chinese description, level and other information of different types of messages. The message header of each message can be assembled according to the information specified in the data collection format file. The message header of each message is spliced together with the message to obtain the data corresponding to each message.
[0076] In some embodiments, the conversion module 304 is also configured to execute the following loop: determine whether i is greater than N, where i is the sequence number of the data in the format data, N is the number of all data in the format data, and the initial value of i is 1; when i is less than or equal to N, perform field check, data range check and data length check on the i-th data; if the i-th data passes all checks, convert the i-th data into the i-th JSON object according to the JSON file format, add the i-th JSON object to the target file, and update i with the value of i plus 1, where the target file is newly created when the first JSON object is obtained; if at least one check of the i-th data fails, delete the i-th data and update i with the value of i plus 1; when i is greater than N, treat the target file as a JSON file and exit the loop.
[0077] There are a total of N data in the format data. Field verification, data range verification and data length verification are performed on each data in sequence according to the sequence number. When each data passes all the verifications, each data is converted into a JSON object according to the JSON file format, and finally a JSON file consisting of multiple JSON objects is obtained. If a data fails one verification, it is determined that the data is unqualified and can be deleted. The target file contains the first JSON object, the second JSON object...the i-th JSON object. When i is greater than N, it means that all data are converted into JSON objects. The target file contains all JSON objects. At this time, the target file is used as a JSON file and the loop is exited.
[0078] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean 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 the present application.
[0079] Figure 4Schematic diagram of an electronic device 4 provided in an embodiment of the present disclosure. Figure 4 As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 401 executes the computer program 403, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0080] The electronic device 4 may include but is not limited to a processor 401 and a memory 402. Those skilled in the art will appreciate that Figure 4 The electronic device 4 is merely an example and does not limit the electronic device 4 , and may include more or less components than those shown in the figure, or different components.
[0081] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0082] The memory 402 may be an internal storage unit of the electronic device 4, for example, a hard disk or memory of the electronic device 4. The memory 402 may also be an external storage device of the electronic device 4, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 4. The memory 402 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 402 is used to store computer programs and other programs and data required by the electronic device.
[0083] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0084] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0085] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for generating a JSON file of vehicle data, characterized in that: include: Collect vehicle operation data in real time; Assembling the operation data according to the data acquisition format file to obtain format data; Performing field verification, data range verification and data length verification on the format data respectively; When all checks are passed, the format data is converted into a JSON file according to the JSON file format; Formatting the JSON file to delete useless information in the JSON file; Encrypting the identification number and / or the value in the JSON file to obtain an encrypted JSON file; After assembling the operation data according to the data acquisition format file to obtain the format data, the method further includes: The format data includes multiple pieces of data; Execute the following loop: Determine whether i is greater than N, where i is the sequence number of the data in the format data, N is the number of all data in the format data, and the initial value of i is 1; When i is less than or equal to N, perform field check, data range check and data length check on the i-th data; If the i-th data passes all checks, convert the i-th data into the i-th JSON object according to the JSON file format, add the i-th JSON object to the target file, and update i with the value of i plus 1, wherein the target file is newly created when the first JSON object is obtained; If at least one check fails for the i-th data item, delete the i-th data item and update i with the value i plus 1; When i is greater than N, the target file is used as the JSON file and the loop is exited.
2. The method according to claim 1, characterized in that: The identification number and / or value in the JSON file is encrypted to obtain an encrypted JSON file, including: Perform the following operations on the identification numbers and / or values in the JSON file in sequence: Replace each byte in the identification number and / or value in the JSON file with the byte obtained by the S-Box lookup table; Performing a circular right shift operation on the rows in the identification numbers and / or values in the JSON file; Performing a mixed operation on the columns of identification numbers and / or numerical values in the JSON file; A bitwise XOR operation is performed using the key and the identification number and / or the value in the JSON file to obtain an encrypted JSON file.
3. The method according to claim 1, characterized in that Performing field verification on the format data includes: Determine whether a required field exists in the message header of each piece of data in the format data and whether the data corresponding to the required field is within a first preset range; If there is a required field and the data corresponding to the required field is within a first preset range, it is determined that the field check has passed; otherwise, it is determined that the field check has failed.
4. The method according to claim 1, characterized in that Performing a data range check on the format data includes: Determine a second preset range of values in each piece of data based on an identification number in a message header of the data in the format; Determine whether the value in each piece of data is within its corresponding second preset range; If so, it is determined that the data range check has passed, otherwise it is determined that the data range check has failed.
5. The method according to claim 1, characterized in that Performing the data length check on the format data includes: Determine the preset length of each piece of data based on the identification number in the message header of the data in the format; Determine whether the data length of each piece of data is the same as the preset length; If they are the same, it is determined that the data length check passes, otherwise it is determined that the data length check fails.
6. The method according to claim 1, characterized in that Assembling the operation data according to the data acquisition format file to obtain format data, including: The operation data includes multiple messages, and the format data includes data corresponding to each message; Determine the identification number, name, Chinese description and level of each message according to the data collection format file; Assemble the message header of each message based on the identification number, name, Chinese description and level of each message; The message headers of each message are concatenated with the message to obtain the data corresponding to each message.
7. A device for generating a JSON file of vehicle data, characterized in that: include: A collection module, configured to collect vehicle operation data in real time; An assembling module is configured to assemble the operation data according to the data acquisition format file to obtain format data; A verification module is configured to perform field verification, data range verification and data length verification on the format data respectively; A conversion module is configured to convert the format data into a JSON file according to the JSON file format when all checks are passed; A formatting module, configured to perform a formatting operation on the JSON file to delete useless information in the JSON file; An encryption module is configured to encrypt the identification number and / or the value in the JSON file to obtain an encrypted JSON file; The format data includes multiple pieces of data, and the conversion module is further configured to execute the following loop: Determine whether i is greater than N, where i is the sequence number of the data in the format data, N is the number of all data in the format data, and the initial value of i is 1; When i is less than or equal to N, perform field check, data range check and data length check on the i-th data; If the i-th data passes all checks, convert the i-th data into the i-th JSON object according to the JSON file format, add the i-th JSON object to the target file, and update i with the value of i plus 1, wherein the target file is newly created when the first JSON object is obtained; If at least one check fails for the i-th data item, delete the i-th data item and update i with the value i plus 1; When i is greater than N, the target file is used as the JSON file and the loop is exited.
8. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Point burying method and device applied to in-vehicle infotainment system, vehicle and storage medium
CN114661607A
Vehicle configuration file generation method and device, electronic equipment and readable storage medium
CN117579683A