Processing method and apparatus for processing string binary data, device, and readable storage medium

By performing line feed compression and target array length label processing on string binary data, combined with the processing of target type and non-target type numbers, the problem of low data processing efficiency in the existing technology is solved, and more efficient data compression and transmission are achieved. .

WO2025015802A1PCT designated stage expired Publication Date: 2025-01-23E-SURFING DIGITAL LIFE TECH CO LTD

Patent Information

Application Number
PCT/CN2023/134809
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-07-19
Filing Date
2023-11-28
Publication Date
2025-01-23

AI Technical Summary

Technical Problem

In the prior art, the processing efficiency of binary data of character strings is not high, resulting in limited data transmission efficiency and affecting user experience.

Method used

By identifying the target string to be processed, a new empty string is obtained. Recognize the target array, calculate the length and label, and place the label in an empty string. The target types and non -target types that appear in the target array are processed, and the stitching is compressed string.

Benefits of technology

Effectively improve the compression efficiency of the string, reduce the transmission cost between the front and the back -end, improve the processing efficiency of binary data, and improve the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023134809_23012025_PF_FP_ABST
    Figure CN2023134809_23012025_PF_FP_ABST
Patent Text Reader

Abstract

The present application provides a method and apparatus for processing string binary data, a device, and a readable storage medium. When binary data of a string needs to be compressed, the present application can be used to identify a target string to be processed, perform line break compression processing, and identify a byte array therein. On the basis of the byte array, a length of the byte array is calculated, and a length label is created for the byte array. Next, the length label of the array is placed in an acquired empty string. Byte-type numbers and non-byte-type numbers in the byte array are processed, and then a string obtained after said processing and the empty string are joined, to obtain a compressed fifth target string. It can thus be seen that the present application can effectively improve the compression efficiency of a string, can effectively reduce the transmission cost between a front end and a back end, and can effectively compress highly repetitive but not identical data, such that the efficiency of processing binary data is improved, thereby effectively improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

String binary data processing method, device, equipment and readable storage medium Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, apparatus, device and readable storage medium for processing string binary data. Background Art

[0002] In actual applications, when transferring data between the front-end and back-end, the data is usually too large, resulting in a slow transfer process, which greatly affects the user experience. Therefore, in order to improve data transmission efficiency, in actual applications, it is often necessary to compress the data being transferred between the front-end and back-end, and then decompress the data to be transferred on the back-end or front-end to achieve fast data transfer.

[0003] Currently, conventional compression methods typically remove line breaks from the data being compressed. For example, for JSON strings, this is often done by simplifying the JSON string's key. While common compression algorithms can effectively reduce the size of JSON data, their limited compression efficiency hinders efficient data transmission. Therefore, a more efficient compression algorithm is needed to process the data being transmitted and improve data transmission efficiency.

[0004] Summary of the Invention

[0005] The present application aims to solve at least one of the above-mentioned technical defects. In view of this, the present application provides a string binary data processing method, device, equipment and readable storage medium to solve the technical defect of low efficiency of string binary data processing in the prior art.

[0006] A method for processing string binary data, comprising:

[0007] Identify the target string to be processed;

[0008] Performing line break compression on the target character string to be processed to obtain a first target character string;

[0009] Get a new first empty string;

[0010] identifying a target array in the first target string;

[0011] Calculating the length of the target array in the first target string and labeling the length of the target array in the first target string;

[0012] placing a label of the length of the target array in the first target string into the first empty string;

[0013] Processing the target type numbers that appear in the target array in the first target character string to obtain a second target character string;

[0014] Concatenate the second target string and the first empty string to obtain a third target string;

[0015] Processing non-target type numbers that appear in the target array in the first target character string to obtain a fourth target character string;

[0016] The third target character string and the fourth target character string are concatenated to obtain a compressed fifth target character string.

[0017] Preferably, the method further comprises:

[0018] The fifth target character string is decompressed to obtain a decompressed sixth target character string.

[0019] Preferably, processing the target type numbers appearing in the target array in the first target character string to obtain the second target character string includes:

[0020] Counting the values ​​of target type numbers appearing in the target array in the first target character string and the subscripts of the numbers of each target type;

[0021] Calculate and record the differences between each pair of array subscripts of the target type digital values ​​that appear in the target array in the first target string;

[0022] The difference between the value of the target type number appearing in the target array in the first target character string and all the array subscripts is concatenated to obtain a second target character string.

[0023] Preferably, the processing of non-target type numbers appearing in the target array in the first target character string to obtain a fourth target character string comprises:

[0024] Sequentially calculate the values ​​of other non-target type numbers that appear in the target array in the first target string;

[0025] Count the subscripts of other non-target type numbers appearing in the target array in the first target string;

[0026] Calculate and record the differences between the array subscripts of the non-target type numbers appearing in the target array in the first target string;

[0027] The differences between the values ​​of the non-target type numbers appearing in the target array in the first target character string and all the array subscripts are concatenated to obtain a fourth target character string.

[0028] Preferably, decompressing the fifth target character string to obtain a decompressed sixth target character string includes:

[0029] Separate the data corresponding to the fifth target string using a delimiter to obtain the array length of the data corresponding to the fifth target string;

[0030] Creating a target array according to the array length of the data corresponding to the fifth target character string, wherein the content of the target array is empty;

[0031] Obtaining the value of each group of data in the array of data corresponding to the fifth target character string;

[0032] Calculating the index value of each group of data in the array of data corresponding to the fifth target character string, and filling the index value into the target array;

[0033] A decompressed sixth target character string is obtained according to the length of the target array, the numbers in the target array, and the positions of the numbers in the target array.

[0034] A device for processing binary data of a character string, comprising:

[0035] A first recognition unit, configured to recognize a target character string to be processed;

[0036] a line break compression unit, configured to perform line break compression on the target character string to be processed to obtain a first target character string;

[0037] A first obtaining unit, used to obtain a new first empty string;

[0038] a second recognition unit, configured to recognize a target array in the first target character string;

[0039] a first calculation unit, configured to calculate the length of a target array in the first target string and label the length of the target array in the first target string;

[0040] a first processing unit, configured to place a label indicating the length of a target array in the first target string into the first empty string;

[0041] a second processing unit, configured to process the target type of numbers appearing in the target array in the first target character string to obtain a second target character string;

[0042] a first concatenation unit, configured to concatenate the second target character string and the first empty character string to obtain a third target character string;

[0043] a third processing unit, configured to process non-target type numbers appearing in the target array in the first target character string to obtain a fourth target character string;

[0044] The second concatenation unit is configured to concatenate the third target character string and the fourth target character string to obtain a compressed fifth target character string.

[0045] Preferably, the device further comprises:

[0046] The decompression unit is configured to decompress the fifth target character string to obtain a decompressed sixth target character string.

[0047] Preferably, the second processing unit includes:

[0048] a first counting unit, configured to count the values ​​of target type numbers appearing in the target array in the first target character string and the subscripts appearing in the numbers of each target type;

[0049] a first calculation unit, configured to calculate and record the difference between each pair of array subscripts of the target type digital values ​​appearing in the target array in the first target character string;

[0050] The third concatenation unit is configured to concatenate the difference between the value of the target type number appearing in the target array in the first target character string and all the array subscripts to obtain a second target character string.

[0051] A character string binary data processing device comprises: one or more processors, and a memory;

[0052] The memory stores computer-readable instructions, which, when executed by the one or more processors, implement the steps of the string binary data processing method as described in any one of the above introductions.

[0053] A readable storage medium stores computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors implement the steps of the string binary data processing method as described in any of the above descriptions.

[0054] From the technical solution described above, it can be seen that when it is necessary to compress the binary data of a string, the method provided in the embodiment of the present application can identify the target string to be processed; and perform line break compression processing on the identified target string to be processed, thereby obtaining a first target string; after obtaining the first target string, in order to better compress the first target string, a new first empty string can be obtained; and a target array in the first target string can be identified; so that the length of the target array in the first target string can be calculated based on the target array in the first target string, and a label can be assigned to the length of the target array in the first target string; further, the label of the length of the target array in the first target string can be placed in the first empty string; after placing the label of the length of the target array in the first target string in the first empty string, the target type numbers appearing in the target array in the first target string can be further processed, thereby obtaining a second target string; then the second target string can be concatenated with the first empty string to obtain a third target string; further, the non-target type numbers appearing in the target array in the first target string can be processed, thereby obtaining a fourth target string; finally, the third target string can be concatenated with the fourth target string to obtain a compressed fifth target string. The fifth target character string is a character string obtained by compressing the character string binary data.

[0055] It can be seen from this that the method provided in the embodiment of the present application can effectively improve the compression efficiency of character strings, effectively reduce the transmission cost between the front end and the back end, effectively compress and process highly repetitive but different data, improve the processing efficiency of binary data, and effectively improve the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 labor.

[0057] FIG1 is a flowchart of a method for processing binary data of a character string provided by an embodiment of the present application;

[0058] FIG2 is a schematic diagram of the structure of a device for processing binary data of a character string according to an embodiment of the present application;

[0059] FIG3 is a hardware structure block diagram of a string binary data processing device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

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

[0061] Given that most of the current string binary data processing solutions are difficult to adapt to complex and changeable business needs, the applicant has studied a string binary data processing solution. When the data to be processed needs to be compressed, the method provided in the embodiment of the present application can effectively compress the string binary data to be processed. The method provided in the embodiment of the present application can not only effectively improve the compression efficiency of the string, but also effectively reduce the transmission cost between the front end and the back end, and can effectively compress highly repetitive but different data, thereby improving the processing efficiency of binary data and effectively improving the user experience.

[0062] The methods provided in the embodiments of the present application can be used in a variety of general-purpose or specialized computing device environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multi-processor devices, and distributed computing environments including any of the above.

[0063] An embodiment of the present application provides a method for processing string binary data. The method can be applied to various data management systems or data processing systems, and can also be applied to various computer terminals or smart terminals. The execution subject can be the processor or server of the computer terminal or smart terminal.

[0064] The following describes the process of the method for processing binary data of a character string according to an embodiment of the present application in conjunction with FIG1 . As shown in FIG1 , the process may include the following steps:

[0065] Step S101: Identify the target character string to be processed.

[0066] Specifically, in actual application processes, the data generated between the front end and the back end may be of different types.

[0067] Therefore, when data needs to be compressed, the method provided in the embodiment of the present application can identify the target character strings to be processed in the front end and the back end.

[0068] in,

[0069] The target string to be processed can be a JSON string.

[0070] Step S102 : performing line break compression processing on the target character string to be processed to obtain a first target character string.

[0071] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can identify the target character string to be processed among a large amount of data.

[0072] After determining the target character string to be processed, in order to better improve the compression processing of the target character string to be processed, the target character string to be processed may be subjected to line wrapping compression processing, thereby obtaining a first target character string.

[0073] Line-feed compression is a method of compressing files or data, reducing their size for easier transmission or storage, saving storage space, and allowing scattered files or data to be grouped together for easier packaging or storage.

[0074] In actual application, since the JSON string may contain line breaks, it is necessary to remove the line breaks first to reduce the size of the JSON string.

[0075] It can be seen from this that performing preliminary compression processing on the first target character string can facilitate subsequent compression processing on the target character string, and can effectively improve the compression processing efficiency of the target character string.

[0076] Step S103: Obtain a new first empty character string.

[0077] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can further perform line break compression processing on the target character string to be processed after determining the target character string to be processed, thereby obtaining the first target character string.

[0078] The first target character string is a character string obtained after preliminary compression processing.

[0079] In order to further efficiently process the first target string, a new first empty string may be obtained to assist in processing the first target string that has undergone preliminary compression processing, so that the first target string can be processed more efficiently.

[0080] For example,

[0081] An empty string may be obtained and named as string S for processing the first target string.

[0082] Step S104: identifying a target array in the first target character string.

[0083] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can obtain a new first empty character string to assist in processing the first target character string that has undergone preliminary compression processing.

[0084] After performing preliminary line break compression processing on the target character string, the target array in the first target character string can be identified.

[0085] in,

[0086] The target array can be a Byte array.

[0087] A byte is a unit of binary data.

[0088] A byte is usually 8 bits long, however, some older computer architectures use different lengths. To avoid confusion, the word "Byte" is usually used instead to describe a byte.

[0089] In most computer systems, a byte is an 8-bit unit of data. Most computers use a byte to represent a single character, number, or other symbol. A byte can also represent a sequence of binary bits. In some computer systems, four bytes represent a word, which is the unit of data that a computer can efficiently process when executing instructions.

[0090] An array of any data type requires 20 bytes of memory, plus 4 bytes for each array dimension, plus the space taken up by the data itself. The memory space taken up by the data can be calculated by multiplying the number of data elements by the size of each element.

[0091] After identifying the target array for the first target string, the first target string may be processed by calculating the length of the target array.

[0092] Step S105 : Calculate the length of the target array in the first target character string and label the length of the target array in the first target character string.

[0093] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can identify the Byte array of the first target character string.

[0094] After the Byte array of the first target string is identified, the length of the Byte array in the first target string may be calculated and a label may be assigned to the length of the Byte array in the first target string.

[0095] For example,

[0096] The Byte array in the first target string that has been compressed by line breaks can be obtained, and the length of the Byte array in the first target string can be calculated, and the label of the length of the Byte array in the first target string can be recorded as num.

[0097] Step S106: Place the label of the length of the target array in the first target character string into the first empty character string.

[0098] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can calculate the length of the Byte array in the first target string after identifying the Byte array of the first target string, and label the length of the Byte array in the first target string.

[0099] Furthermore, the label of the length of the target array in the first target string may be placed in the first empty string obtained above.

[0100] For example,

[0101] The Byte array in the first target string that has been compressed with newlines can be obtained, and the length of the Byte array in the first target string can be calculated. The label of the length of the Byte array in the first target string is recorded as num, and "num" is used as a new label and placed in the new empty string S obtained above.

[0102] Step S107 : Process the target type numbers appearing in the target array in the first target character string to obtain a second target character string.

[0103] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can calculate the length of the Byte array in the first target string after identifying the Byte array of the first target string, label the length of the Byte array in the first target string, and place the label of the length of the target array in the first target string in the first empty string obtained above.

[0104] In actual applications, a JSON string may include Byte type values ​​or non-Byte type data.

[0105] Therefore, after calculating the length of the Byte array in the first target string, labeling the length of the Byte array in the first target string, and placing the label of the length of the target array in the first target string in the first empty string obtained above, the target type numbers appearing in the target array in the first target string can be further processed, thereby obtaining the second target string.

[0106] in,

[0107] The target type can be a Byte type number.

[0108] Step S108: Concatenate the second target character string and the first empty character string to obtain a third target character string.

[0109] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can process the target type numbers appearing in the target array in the first target character string to obtain the second target character string.

[0110] After processing the Byte-type numbers appearing in the target array in the first target string to obtain a second target string, the second target string may be further concatenated with the first empty string to obtain a third target string.

[0111] Step S109: Process the non-target type numbers appearing in the target array in the first target character string to obtain a fourth target character string.

[0112] Specifically, as can be seen from the above introduction, in actual application, a JSON string may include Byte type values ​​or non-Byte type data.

[0113] As can be seen from the above introduction, the method provided in the embodiment of the present application can process the Byte type numbers appearing in the target array in the first target string to obtain a second target string, and then further concatenate the second target string with the first empty string to obtain a third target string.

[0114] Furthermore, the method provided in the embodiment of the present application can also process non-target type numbers appearing in the target array in the first target character string to obtain a fourth target character string.

[0115] For example,

[0116] The method provided in the embodiment of the application can also process non-Byte type numbers appearing in the target array in the first target string to obtain a fourth target string.

[0117] Step S110 : Concatenate the third target character string and the fourth target character string to obtain a compressed fifth target character string.

[0118] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can process non-target type numbers and target type numbers appearing in the target array in the first target string respectively to obtain the fourth target string and the third target string.

[0119] Furthermore, the third target character string and the fourth target character string may be concatenated to obtain a compressed fifth target character string.

[0120] For example,

[0121] The method provided in the embodiment of the present application can process non-Byte type numbers and Byte type numbers appearing in the Byte array in the first target string respectively to obtain a fourth target string and a third target string, and then concatenate the third target string with the fourth target string to obtain a compressed fifth target string.

[0122] It can be seen from this that the method provided in the embodiment of the present application has high compression efficiency for the target character string and can also include highly repetitive but different data into the compression range.

[0123] Step S111 : decompress the fifth target character string to obtain a decompressed sixth target character string.

[0124] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can perform efficient compression processing on the target character string to be processed.

[0125] For example, the method provided in the embodiment of the present application can efficiently compress JSON strings.

[0126] In actual application, the method provided in the embodiment of the present application can not only efficiently compress the JSON string, but also decompress the compressed ISON string to restore the original JSON string.

[0127] Therefore, after compressing the target character string to obtain the fifth target character string, the method provided in the embodiment of the present application can further decompress the fifth target character string to obtain a decompressed sixth target character string.

[0128] It can be seen from the technical solution introduced above that when the data to be processed needs to be compressed, the method provided in the embodiment of the present application can effectively compress the binary data of the string to be processed. The method provided in the embodiment of the present application can not only effectively improve the compression efficiency of the string, but also effectively reduce the transmission cost between the front end and the back end, and can effectively compress highly repetitive but different data, thereby improving the processing efficiency of binary data and effectively improving the user experience.

[0129] As can be seen from the above description, the method provided in the embodiment of the present application can process the target type of numbers appearing in the target array in the first target string to obtain the second target string. The following describes the process, which may include the following steps:

[0130] Step S201 , counting the values ​​of target type numbers appearing in the target array in the first target character string and the subscripts of the numbers of each target type appearing.

[0131] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can identify the target array in the first target character string.

[0132] Furthermore, the values ​​of the target type numbers appearing in the target array in the first target string and the subscripts where the numbers of each target type appear can be further counted, so that the difference between the array subscripts where the values ​​of the target type numbers appearing in the target array in the first target string appear can be calculated based on the values ​​of the target type numbers appearing in the target array in the first target string and the subscripts where the numbers of each target type appear.

[0133] For example,

[0134] The values ​​of Byte-type numbers appearing in the Byte array in the first target string may be counted, and the subscripts of the Byte-type numbers appearing in the first target string may be counted.

[0135] For example,

[0136] The Byte type number appearing in the Byte array of a string Z is -120, and the subscripts of the Byte type numbers appearing in the Byte array of the string Z are 1, 15, 30, and 39 respectively. Then, the value of the Byte type number appearing in the Byte array of the string Z can be counted as -120, and the subscripts of each Byte type number -120 appearing in the string Z can be counted as 1, 15, 30, and 39 respectively.

[0137] Step S202 , calculating and recording the differences between each pair of array subscripts of target type digital values ​​appearing in the target array in the first target character string.

[0138] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can count the values ​​of the target type numbers appearing in the target array in the first target character string and the subscripts appearing in the numbers of each target type.

[0139] Furthermore, the differences between the array subscripts of the target type numbers appearing in the target array in the first target character string may be calculated and recorded.

[0140] For example,

[0141] The Byte type number appearing in the Byte array of a string Z is -120, and the Byte type number subscripts appearing in the Byte array of the string Z are 1, 15, 30, and 39 respectively. Then, the value of the Byte type number -120 appearing in the Byte array of the string Z can be calculated and recorded. The differences between the array subscripts that appear are 1, 14, 15, and 9 respectively.

[0142] Step S203: Concatenate the values ​​of the target type numbers appearing in the target array in the first target character string and the differences between all array subscripts to obtain a second target character string.

[0143] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can calculate and record the difference between the array subscripts of the target type digital values ​​appearing in the target array in the first target string;

[0144] Furthermore, the method provided in the embodiment of the present application can also concatenate the values ​​of the target type numbers appearing in the target array in the first target string and the differences between all array subscripts to obtain a second target string.

[0145] For example,

[0146] The Byte type number appearing in the Byte array in a string Z is -120, and the Byte type number subscripts appearing in the Byte array in the string Z are 1, 15, 30, and 39 respectively. The difference between the array subscripts where the value of -120 of the Byte type number appears in the Byte array in the string Z is calculated and recorded as 1, 14, 15, and 9 respectively. The data with a value of -120 obtained from the string Z and the difference between the array subscripts where the value of -120 of the Byte type number appears in the Byte array in the string Z can be concatenated respectively, which can be recorded as -120&1&14&15&9.

[0147] It can be seen from the technical solution introduced above that when the data to be processed needs to be compressed, the method provided in the embodiment of the present application can process the target type numbers appearing in the target array in the first target string to obtain a second target string, so that a compressed target string can be obtained based on the second target string.

[0148] As can be seen from the above description, the method provided in the embodiment of the present application can process non-target type numbers appearing in the target array in the first target string, and obtain a fourth target string including:

[0149] Step S301 , sequentially calculating the values ​​of other non-target type numbers appearing in the target array in the first target character string.

[0150] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can identify the target array in the first target character string.

[0151] Furthermore, the values ​​of other non-target type numbers appearing in the target array in the first target string can be further counted, so that the difference between the array subscripts in which the values ​​of the target type numbers appearing in the target array in the first target string appear can be calculated based on the values ​​of other non-target type numbers appearing in the target array in the first target string.

[0152] For example,

[0153] The values ​​of non-Byte type numbers appearing in the Byte array in the first target string can be counted.

[0154] For example,

[0155] If the number of non-Byte type numbers appearing in the Byte array of a string Z is 120, then the value of the Byte type numbers appearing in the Byte array of the string Z can be counted separately to be 120.

[0156] Step S302: Count the subscripts of other non-target type digital values ​​that appear in the target array in the first target character string.

[0157] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can identify the target array in the first target character string.

[0158] Furthermore, the subscripts of other non-target type numbers appearing in the target array in the first target string can be further counted, so that the differences between the array subscripts of other non-target type numbers appearing in the target array in the first target string can be calculated based on the subscripts of other non-target type numbers appearing in the target array in the first target string.

[0159] For example,

[0160] The values ​​of non-Byte type numbers appearing in the Byte array in the first target string may be counted, and the subscripts of each non-Byte type number appearing in the first target string may be counted.

[0161] For example,

[0162] The non-Byte type number that appears in the Byte array of a string Z is 120, and the subscripts of the non-Byte type numbers that appear in the Byte array of the string Z are 2, 16, 31, and 40 respectively. Then, we can count the value of the non-Byte type number that appears in the Byte array of the string Z as 120, and count the subscripts of each non-Byte type number 120 in the string Z as 2, 16, 31, and 40 respectively.

[0163] Step S303 , calculating and recording the differences between the array subscripts of the non-target type numbers appearing in the target array in the first target character string.

[0164] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can count the values ​​of other non-target type numbers appearing in the target array in the first target string and the subscripts of each non-target type number.

[0165] Furthermore, the differences between the array subscripts of other non-target type numbers appearing in the target array in the first target character string may be calculated and recorded.

[0166] For example,

[0167] The non-Byte type number that appears in the Byte array of a string Z is 120, and the subscripts of the non-Byte type numbers that appear in the Byte array of the string Z are 2, 16, 31, and 40 respectively. Then, the differences between the array subscripts of the non-Byte type number 120 that appears in the Byte array of the string Z can be calculated and recorded as 2, 14, 15, and 9 respectively.

[0168] Step S304: Concatenate the differences between the values ​​of the non-target type numbers appearing in the target array in the first target character string and all the array subscripts to obtain a fourth target character string.

[0169] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can calculate and record the difference between the array subscripts of the values ​​of other non-target types of numbers appearing in the target array in the first target string;

[0170] Furthermore, the method provided in the embodiment of the present application can also concatenate the values ​​of other non-target type numbers appearing in the target array in the first target string and the differences between all array subscripts to obtain a fourth target string.

[0171] For example,

[0172] The non-Byte type number that appears in the Byte array of a string Z is 120. The subscripts of the non-Byte type number that appear in the Byte array of the string Z are 2, 16, 31, and 40 respectively. The differences between the array subscripts where the value of the non-Byte type number 120 appears in the Byte array of the string Z are calculated and recorded as 2, 14, 15, and 9 respectively. The data with a value of 120 obtained from the string Z and the differences between the array subscripts where the value of the non-Byte type number 120 appears in the Byte array of the string Z can be concatenated together, which can be recorded as 120&2&14&15&9.

[0173] It can be seen from the technical solution introduced above that when the data to be processed needs to be compressed, the method provided in the embodiment of the present application can process the non-target type numbers appearing in the target array in the first target string to obtain a fourth target string, so that the compressed target string can be obtained based on the fourth target string.

[0174] As can be seen from the above description, the method provided in the embodiment of the present application can decompress the fifth target character string to obtain a decompressed sixth target character string, including:

[0175] Step S401: Separate the data corresponding to the fifth target character string with a delimiter to obtain the array length of the data corresponding to the fifth target character string.

[0176] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can not only compress the JSON string to be processed, but also decompress and restore the JSON string that has been compressed to obtain the uncompressed JSON string.

[0177] Therefore, in order to decompress and restore the compressed fifth target string, after obtaining the fifth target string, the data corresponding to the fifth target string may be separated by a delimiter to obtain the array length of the data corresponding to the fifth target string.

[0178] For example,

[0179] The data corresponding to the fifth target string may be separated by using a comma as a delimiter to obtain the array length of the data corresponding to the fifth target string.

[0180] For example,

[0181] Different numbers can be separated by commas.

[0182] for example:

[0183] The subscripts of the number -120 are 1, 15, 30, 39;

[0184] The subscripts of the number -110 are 3, 16, 17, 33;

[0185] Then write "-120&1&14&15&9" and "-110&3&13&1&16" with a comma between them.

[0186] Step S402: Create a target array according to the array length of the data corresponding to the fifth target character string, wherein the content of the target array is empty.

[0187] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can use a comma as a delimiter to separate the data corresponding to the fifth target string, and obtain the array length of the data corresponding to the fifth target string.

[0188] After determining the array length of the data corresponding to the fifth target character string, a target array may be created based on the array length of the data corresponding to the fifth target character string.

[0189] in,

[0190] The length of the created array is set according to the length value of the target type data in the fifth target string;

[0191] The content of the created target array is empty so that it can be filled with content according to the decompression process of the fifth target character string.

[0192] Step S403: Obtain the value of each group of data in the array of data corresponding to the fifth target character string.

[0193] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can, after determining the array length of the data corresponding to the fifth target string, further create a target array based on the array length of the data corresponding to the fifth target string.

[0194] After creating an empty array, you need to fill the created empty array with content.

[0195] Therefore, after creating an empty array, the value of each group of data in the array of data corresponding to the fifth target string can be further obtained, so that the value of each group of data in the array of data corresponding to the fifth target string can be filled into the created empty array.

[0196] Step S404 : Calculate the index value of each group of data in the array of data corresponding to the fifth target character string, and fill it into the target array.

[0197] Specifically, as can be seen from the above introduction, the method provided in the embodiment of the present application can create a new empty array and obtain the value of each group of data in the array of data corresponding to the fifth target string.

[0198] Furthermore, the index value of each group of data in the array of data corresponding to the fifth target character string may be calculated and filled into the target array.

[0199] in,

[0200] The index value of each group of data in the array of data corresponding to the fifth target character string is the subscript of each data.

[0201] For example,

[0202] From the above introduction, we can know that the compression result of a string Z is: -120&1&14&15&9.

[0203] To calculate the index value of each group of data in the array of data corresponding to the string Z, it is necessary to add the data other than the first digit of the previous data "-120&1&14&15&9", which represents the index positions 1, 15, 30, and 39, and then fill -120 into the four positions 1, 15, 30, and 39.

[0204] Step S405 , obtaining a decompressed sixth target character string according to the length of the target array, the numbers in the target array, and the positions of the numbers in the target array.

[0205] Specifically, from the above introduction, it can be seen that the method provided in the embodiment of the present application can be processed according to the fifth target string, so that a target array can be created and the length of the target array, the numbers of the target array, and the positions of each number in the target array can be determined. Furthermore, based on the length of the target array, the numbers of the target array, and the positions of each number in the target array, the decompressed sixth target string can be obtained.

[0206] It can be seen from this that the sixth target character string may be a character string obtained by decompressing the fifth target character string.

[0207] It can be seen from the technical solution introduced above that the method provided in the embodiment of the present application can not only compress the JSON string to be processed, but also decompress and restore the JSON string that has been compressed to obtain the uncompressed JSON string.

[0208] In actual application, data transmission between the front-end and the back-end is often involved. Next, taking the processing of JSON strings as an example, the implementation method provided by the embodiment of the present application is introduced. The process may include the following:

[0209] 1. The process of inverted compression of JSON string binary data includes the following steps:

[0210] Step A1: Get the string value after removing line breaks

[0211] In actual application, since the JSON string may contain line breaks, it is necessary to remove the line breaks first to reduce the size of the JSON string.

[0212] Step B1: Get the Byte array in the JSON string

[0213] For JSON strings, if the key values ​​are similar, the Byte array data is highly overlapping.

[0214] For example,

[0215] For example, the data in the two arrays with the key "I love you China" and the key "I love your motherland" are highly overlapping.

[0216] Such data cannot be compressed using the original compression algorithm. After being converted into a Byte array, their data values ​​and index values ​​can be recorded for compression.

[0217] Step C1: Calculate the array size, data content, and index in the JSON string, and calculate the index difference of the array in the JSON string

[0218] When restoring compressed data, you must know the size of the array before compression, if you use the index directly, if these indexes are large.

[0219] For example, the index position of -120 is 12345, 12349, and 12357. The compression cost of such a position will be relatively high, but if 12345, 4, and 8 are used, the compression cost will be greatly reduced.

[0220] 2. The process of inverted decompression of JSON string binary data can include the following steps:

[0221] Step A2: Get the JSON string to be processed and split it

[0222] The compressed JSON characters can be separated by commas and can be separated into array G.

[0223] Step B2: Get the length of array G and create a new Byte array F

[0224] To create a new Byte array F, you first need to know the array length. Therefore, you need to get the first piece of data in the compressed JSON string.

[0225] Step C2: Get the content of array F and the subscript difference, calculate the subscript of array F, and fill the new array

[0226] Get all the data except 0 in array G, use & to split each group of data into array I, get the first data in array I as the content, traverse and add the other data to get the array index, and record it in array F.

[0227] Step D: Restore to JSON string

[0228] Restore array F to a JSON string, which is the required string before compression.

[0229] For example, after the data in array D is filled, the string to be restored can be obtained through the JAVA method new String() function.

[0230] The following describes a string binary data processing device provided in an embodiment of the present application. The string binary data processing device described below and the string binary data processing method described above can be referenced to each other.

[0231] See FIG2 , which is a schematic structural diagram of a string binary data processing device disclosed in an embodiment of the present application.

[0232] As shown in FIG2 , the string binary data processing device may include:

[0233] A first recognition unit 101 is used to recognize a target character string to be processed;

[0234] A line break compression unit 102 is configured to perform line break compression on the target character string to be processed to obtain a first target character string;

[0235] A first acquiring unit 103 is configured to acquire a new first empty string;

[0236] A second recognition unit 104 is configured to recognize a target array in the first target character string;

[0237] A first calculation unit 105 is configured to calculate the length of a target array in the first target string and label the length of the target array in the first target string;

[0238] A first processing unit 106 is configured to place a label indicating the length of the target array in the first target string into the first empty string;

[0239] A second processing unit 107 is configured to process the target type of numbers appearing in the target array in the first target character string to obtain a second target character string;

[0240] A first concatenation unit 108 is configured to concatenate the second target character string and the first empty character string to obtain a third target character string;

[0241] A third processing unit 109 is configured to process non-target type numbers appearing in the target array in the first target character string to obtain a fourth target character string;

[0242] The second concatenation unit 110 is configured to concatenate the third target character string and the fourth target character string to obtain a compressed fifth target character string.

[0243] From the technical solution described above, it can be seen that when it is necessary to compress the binary data of a string, the device provided in the embodiment of the present application can identify the target string to be processed; and perform line break compression processing on the identified target string to be processed, thereby obtaining a first target string; after obtaining the first target string, in order to better compress the first target string, a new first empty string can be obtained; and a target array in the first target string can be identified; so that the length of the target array in the first target string can be calculated based on the target array in the first target string, and a label can be assigned to the length of the target array in the first target string; further, the label of the length of the target array in the first target string can be placed in the first empty string; after placing the label of the length of the target array in the first target string in the first empty string, the target type numbers appearing in the target array in the first target string can be further processed, thereby obtaining a second target string; then the second target string can be concatenated with the first empty string to obtain a third target string; further, the non-target type numbers appearing in the target array in the first target string can be processed, thereby obtaining a fourth target string; finally, the third target string can be concatenated with the fourth target string to obtain a compressed fifth target string. The fifth target character string is a character string obtained by compressing the character string binary data.

[0244] It can be seen from this that when the data to be processed needs to be compressed, the device provided in the embodiment of the present application can effectively compress the binary data of the string to be processed. The device provided in the embodiment of the present application can not only effectively improve the compression efficiency of the string, but also effectively reduce the transmission cost between the front end and the back end, and can effectively compress highly repetitive but different data, thereby improving the processing efficiency of binary data and effectively improving the user experience.

[0245] Further optionally, the device may also include:

[0246] The decompression unit is configured to decompress the fifth target character string to obtain a decompressed sixth target character string.

[0247] Further optionally, the second processing unit may include:

[0248] a first counting unit, configured to count the values ​​of target type numbers appearing in the target array in the first target character string and the subscripts appearing in the numbers of each target type;

[0249] a first calculation unit, configured to calculate and record the difference between each pair of array subscripts of the target type digital values ​​appearing in the target array in the first target character string;

[0250] The third concatenation unit is configured to concatenate the difference between the value of the target type number appearing in the target array in the first target character string and all the array subscripts to obtain a second target character string.

[0251] Among them, the specific processing flow of each unit included in the above-mentioned string binary data processing device can refer to the relevant introduction of the string binary data processing method part above, and will not be repeated here.

[0252] The string binary data processing apparatus provided in the embodiments of the present application can be applied to string binary data processing devices, such as terminals such as mobile phones and computers. Optionally, FIG3 shows a block diagram of the hardware structure of a string binary data processing device. Referring to FIG3 , the hardware structure of the string binary data processing device may include: at least one processor 1, at least one communication interface 2, at least one memory 3, and at least one communication bus 4.

[0253] In an embodiment of the present application, the number of processor 1 , communication interface 2 , memory 3 , and communication bus 4 is at least one, and the processor 1 , communication interface 2 , and memory 3 communicate with each other through the communication bus 4 .

[0254] The processor 1 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application;

[0255] The memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory;

[0256] The memory stores a program, and the processor can call the program stored in the memory, wherein the program is used to implement various processing flows in the aforementioned terminal character string binary data processing solution.

[0257] An embodiment of the present application further provides a readable storage medium, which may store a program suitable for execution by a processor, wherein the program is used to implement various processing flows of the aforementioned terminal in the string binary data processing solution.

[0258] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0259] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0260] The above description of the disclosed embodiments is intended to enable those skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. The various embodiments may be combined with one another. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for processing binary data of a character string, characterized in that: include: Identify the target string to be processed; Perform line break compression processing on the target character string to be processed to obtain a first target character string; Get a new first empty string; identifying a target array in the first target string; Calculating the length of the target array in the first target string and labeling the length of the target array in the first target string; placing a label of the length of the target array in the first target string into the first empty string; Processing the target type numbers appearing in the target array in the first target character string to obtain a second target character string; Concatenate the second target string and the first empty string to obtain a third target string; Processing non-target type numbers appearing in the target array in the first target character string to obtain a fourth target character string; The third target character string is concatenated with the fourth target character string to obtain a compressed fifth target character string.

2. The method according to claim 1, characterized in that The method further includes: The fifth target character string is decompressed to obtain a decompressed sixth target character string.

3. The method according to claim 1, characterized in that The step of processing the target type numbers appearing in the target array in the first target string to obtain the second target string includes: Counting the values ​​of the target type numbers appearing in the target array in the first target character string and the subscripts of the numbers of each target type; Calculate and record the differences between the array subscripts of the target type numbers appearing in the target array in the first target character string; The difference between the value of the target type number appearing in the target array in the first target character string and all the array subscripts is concatenated to obtain a second target character string.

4. The method according to claim 1, characterized in that The processing of the non-target type of numbers appearing in the target array in the first target string to obtain the fourth target string includes: Sequentially calculate the values ​​of other non-target type numbers that appear in the target array in the first target string; Count the subscripts of other non-target type digital values ​​that appear in the target array in the first target string; Calculate and record the differences between the array subscripts of the non-target type numbers appearing in the target array in the first target string; The difference between the value of the non-target type number appearing in the target array in the first target character string and all the array subscripts is concatenated to obtain a fourth target character string.

5. The method according to claim 2, characterized in that: The decompressing the fifth target character string to obtain a decompressed sixth target character string includes: Separate the data corresponding to the fifth target string with a separator to obtain the array length of the data corresponding to the fifth target string; Creating a target array according to the array length of the data corresponding to the fifth target character string, wherein the content of the target array is empty; Obtain the value of each group of data in the array of data corresponding to the fifth target character string; Calculate the index value of each group of data in the array of data corresponding to the fifth target character string, and fill it into the target array; A decompressed sixth target character string is obtained according to the length of the target array, the numbers in the target array, and the positions of the numbers in the target array.

6. A string binary data processing device, characterized in that: include: A first recognition unit, used for recognizing a target character string to be processed; A line break compression unit, used for performing line break compression processing on the target character string to be processed to obtain a first target character string; A first obtaining unit, used to obtain a new first empty string; A second recognition unit, used for recognizing a target array in the first target character string; a first calculation unit, configured to calculate the length of a target array in the first target string and label the length of the target array in the first target string; A first processing unit, configured to place a label of the length of the target array in the first target string into the first empty string; A second processing unit, configured to process the target type numbers appearing in the target array in the first target character string to obtain a second target character string; A first concatenation unit, configured to concatenate the second target character string with the first empty character string to obtain a third target character string; A third processing unit is used to process non-target type numbers appearing in the target array in the first target character string to obtain a fourth target character string; The second concatenation unit is used to concatenate the third target character string with the fourth target character string to obtain a compressed fifth target character string.

7. The device according to claim 6, characterized in that The device also includes: The decompression unit is used to decompress the fifth target character string to obtain a decompressed sixth target character string.

8. The device according to claim 6, characterized in that The second processing unit comprises: A first counting unit, used for counting the values ​​of the target type numbers appearing in the target array in the first target character string and the subscripts appearing in the numbers of each target type; A first calculation unit, used for calculating and recording the difference between the array subscripts of the target type of digital values ​​appearing in the target array in the first target character string. The third concatenation unit is used to concatenate the values ​​of the target type numbers appearing in the target array in the first target character string and the differences between all array subscripts to obtain a second target character string.

9. A string binary data processing device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the string binary data processing method as described in any one of claims 1 to 5 are implemented.

10. A readable storage medium, characterized in that: The readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors implement the steps of the string binary data processing method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • JSON character string data compression method and device and storage medium

    CN116054840A

  • Data processing method, device and equipment and computer storage medium

    CN116167380A

  • Data processing method and device, computer equipment and computer readable storage medium

    CN116257595A

  • Character string binary data processing method, device and equipment and readable storage medium

    CN116933736A

  • Data compression device and data decompression device

    US20170373702A1

Cited By

  • Raster image compression and reconstruction method and device, computer equipment and storage medium

    CN121810823A