Streaming data analysis method and device, medium and equipment

By identifying line breaks in streaming data and judging the integrity line by line, it solves the problem of parsing errors in JSON parsers when processing streaming data and improves the stability and reliability of data processing.

CN118740960APending Publication Date: 2024-10-01CHENGDU LUYI TECH CO LTD
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410791142.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing JSON parsers cannot correctly parse data when processing streaming multi-line JSON object strings, resulting in parsing errors and inability to effectively handle data split into multiple fragments.

Method used

By identifying line breaks in the streaming data, the data is parsed into at least one line of JSON object string, and it is judged line by line whether it contains a complete JSON object. If it is incomplete, continue to parse and splice the next piece of data until the complete JSON object is extracted.

Benefits of technology

It effectively avoids parsing errors and improves the stability and reliability of streaming data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118740960A_ABST
    Figure CN118740960A_ABST
Patent Text Reader

Abstract

The invention discloses an analysis method and device for streaming data, a medium and equipment, and the method comprises the steps: receiving the streaming data, analyzing the streaming data into at least one line of JSON object character strings through recognizing a line feed in the streaming data, and taking the JSON object character strings as to-be-recognized character strings; then judging whether the character string to be recognized contains a complete JSON object or not; if the to-be-identified character string does not contain the complete JSON object, continuing to analyze the streaming data based on the received next streaming data, splicing the analysis result to the to-be-identified character string, and returning to judge whether the to-be-identified character string contains the complete JSON object until the to-be-identified character string contains the complete JSON object. And extracting a complete JSON object from the character string to be identified. According to the embodiment of the invention, analysis errors can be effectively avoided, and the stability and reliability of data processing are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer science and technology, and in particular to a method, device, medium and equipment for analyzing streaming data. Background Art

[0002] In modern computer networks, streaming data transmission is a common way of data exchange, especially in real-time data processing and big data technology. In many practical applications, such as real-time data streams, log systems, and network communications, data is often transmitted in the form of streams. For example, in an IoT system, a device may continuously send sensor data; or in an online chat application, a server may push chat messages in real time. These data are usually transmitted in JSON format. Due to network latency or transmission efficiency considerations, these JSON objects may be transmitted across multiple responses, and even one response may contain multiple JSON objects, and sometimes even one JSON object may span multiple responses.

[0003] In the related art, there are some problems in the JSON parsing method when processing such multi-line JSON object strings, mainly manifested in the inability to parse the data correctly. Specifically, the existing JSON parser assumes that the input data is a single complete JSON object. However, in streaming transmission, the data will be divided into multiple fragments, which may easily cause the parser to be unable to correctly process these fragments and thus unable to parse the data correctly. Therefore, how to improve the accuracy and stability of streaming data parsing has always been a concern of the industry. Summary of the invention

[0004] In view of this, the embodiments of the present application at least provide a method, apparatus, medium and device for parsing streaming data, which can effectively avoid parsing errors and improve the stability and reliability of data processing.

[0005] The present disclosure provides a streaming data parsing method, including:

[0006] Receive streaming data, and parse the streaming data into at least one line of JSON object string by identifying line breaks in the streaming data, and use the JSON object string as a string to be identified;

[0007] Determine whether the string to be identified contains a complete JSON object;

[0008] If the string to be identified does not contain a complete JSON object, the streaming data parsing will continue based on the next streaming data received and the parsing result will be concatenated after the string to be identified, and the process will return to determine whether the string to be identified contains a complete JSON object. If it is determined that the string to be identified contains a complete JSON object, the complete JSON object will be extracted from the string to be identified.

[0009] In a possible implementation, after extracting the complete JSON object from the character string to be identified, the method further includes:

[0010] If the string to be identified contains a remaining string after the complete JSON object is extracted, then based on the next stream data received, continue to parse the stream data and concatenate the parsing result after the remaining string to form a new string to be identified;

[0011] If the string to be identified does not contain any remaining string after the complete JSON object is extracted, the streaming data parsing is continued based on the next stream data received and the parsing result is used as a new string to be identified.

[0012] In a possible implementation, if the string to be identified contains a remaining string after the complete JSON object is extracted, then based on the next stream data received, continue to parse the stream data and concatenate the parsing result after the remaining string to form a new string to be identified, including:

[0013] If the character string to be identified contains a remaining character string after the complete JSON object is extracted, identifying the positional relationship between the remaining character string and the complete JSON object;

[0014] If the remaining character strings are all after the complete JSON object, then based on the next piece of streaming data received, continue to parse the streaming data and concatenate the parsing results after the remaining character strings to form a new character string to be identified;

[0015] If the remaining character strings are all located before the complete JSON object, the remaining character strings are deleted, and based on the next piece of streaming data received, the streaming data parsing is continued and the parsing result is used as a new character string to be identified;

[0016] If a part of the remaining string is located before the complete JSON object, the remaining string before the complete JSON object is deleted, and based on the next streaming data received, the streaming data parsing is continued and the parsing result is spliced ​​after the remaining string after the complete JSON object to form a new string to be identified.

[0017] In a possible implementation, the method further includes:

[0018] Determine that the streaming data corresponding to the remaining deleted character string is the problematic streaming data, and generate error information based on the problematic streaming data;

[0019] Based on the error information, a data retransmission request is sent to the terminal device corresponding to the problematic streaming data.

[0020] In a possible implementation, the determining whether the to-be-recognized string contains a complete JSON object includes:

[0021] Identify the boundary markers in the character string to be identified line by line, wherein the boundary markers include a preset start marker and a preset end marker;

[0022] Based on the boundary mark in the character string to be identified, it is determined whether the character string to be identified already contains a complete JSON object, wherein a preset start tag and a preset end tag in the complete JSON object match each other.

[0023] In a possible implementation manner, after receiving the streaming data, the method further includes:

[0024] storing the streaming data in a data buffer;

[0025] Accordingly, the step of parsing the streaming data into at least one line of JSON object string by identifying line breaks in the streaming data includes:

[0026] Taking out a piece of streaming data from the data buffer in a first-in-first-out order, and parsing the streaming data into at least one line of JSON object string by identifying a line break character in the streaming data;

[0027] Correspondingly, if the string to be identified does not contain a complete JSON object, then based on the next stream data received, continue to parse the stream data and splice the parsing result after the string to be identified, including:

[0028] If the string to be identified does not contain a complete JSON object, a stream data is taken out from the data buffer in a first-in-first-out order for stream data parsing, and the parsing result is spliced ​​after the string to be identified.

[0029] In a possible implementation manner, receiving streaming data includes:

[0030] Receiving streaming data for any one of a plurality of services, wherein the streaming data includes a service identifier and a data body;

[0031] Accordingly, storing the streaming data in a data buffer includes:

[0032] Identify the service identifier carried by the streaming data, and store the data body in the streaming data in a data buffer corresponding to the service identifier;

[0033] Accordingly, after extracting the complete JSON object from the string to be identified, the method further includes:

[0034] Consume based on the business type corresponding to the extracted complete JSON object.

[0035] The present disclosure provides a streaming data parsing device, including:

[0036] A data parsing module, used for receiving streaming data, and parsing the streaming data into at least one line of JSON object string by identifying line breaks in the streaming data, and using the JSON object string as a string to be identified;

[0037] A string determination module is used to determine whether the string to be identified contains a complete JSON object;

[0038] The string concatenation module is used to continue streaming data parsing and concatenate the parsing result after the string to be identified if the string to be identified does not contain a complete JSON object based on the next streaming data received, and return to determine whether the string to be identified contains a complete JSON object. When it is determined that the string to be identified contains a complete JSON object, the complete JSON object is extracted from the string to be identified.

[0039] In a possible implementation, the string concatenation module is further used for:

[0040] If the string to be identified contains a remaining string after the complete JSON object is extracted, then based on the next stream data received, continue to parse the stream data and concatenate the parsing result after the remaining string to form a new string to be identified;

[0041] If the string to be identified does not contain any remaining string after the complete JSON object is extracted, the streaming data parsing is continued based on the next stream data received and the parsing result is used as a new string to be identified.

[0042] In a possible implementation, the string concatenation module is further used for:

[0043] If the character string to be identified contains a remaining character string after the complete JSON object is extracted, identifying the positional relationship between the remaining character string and the complete JSON object;

[0044] If the remaining character strings are all after the complete JSON object, then based on the next piece of streaming data received, continue to parse the streaming data and concatenate the parsing results after the remaining character strings to form a new character string to be identified;

[0045] If the remaining character strings are all located before the complete JSON object, the remaining character strings are deleted, and based on the next piece of streaming data received, the streaming data parsing is continued and the parsing result is used as a new character string to be identified;

[0046] If a part of the remaining string is located before the complete JSON object, the remaining string before the complete JSON object is deleted, and based on the next streaming data received, the streaming data parsing is continued and the parsing result is spliced ​​after the remaining string after the complete JSON object to form a new string to be identified.

[0047] In a possible implementation, the string concatenation module is further used for:

[0048] Determine that the streaming data corresponding to the remaining deleted character string is the problematic streaming data, and generate error information based on the problematic streaming data;

[0049] Based on the error information, a data retransmission request is sent to the terminal device corresponding to the problematic streaming data.

[0050] In a possible implementation, the character string determination module is specifically used to:

[0051] Identify the boundary markers in the character string to be identified line by line, wherein the boundary markers include a preset start marker and a preset end marker;

[0052] Based on the boundary mark in the character string to be identified, it is determined whether the character string to be identified already contains a complete JSON object, wherein a preset start tag and a preset end tag in the complete JSON object match each other.

[0053] In a possible implementation, the data parsing module is further used to:

[0054] storing the streaming data in a data buffer;

[0055] Accordingly, the data parsing module is also used for:

[0056] Taking out a piece of streaming data from the data buffer in a first-in-first-out order, and parsing the streaming data into at least one line of JSON object string by identifying a line break character in the streaming data;

[0057] Accordingly, the string concatenation module is also used for:

[0058] If the string to be identified does not contain a complete JSON object, a stream data is taken out from the data buffer in a first-in-first-out order for stream data parsing, and the parsing result is spliced ​​after the string to be identified.

[0059] In a possible implementation, the data parsing module is specifically used to:

[0060] Receiving streaming data for any one of a plurality of services, wherein the streaming data includes a service identifier and a data body;

[0061] Accordingly, the data parsing module is also used for:

[0062] Identify the service identifier carried by the streaming data, and store the data body in the streaming data in a data buffer corresponding to the service identifier;

[0063] Accordingly, the string concatenation module is also used for:

[0064] Consume based on the business type corresponding to the extracted complete JSON object.

[0065] An embodiment of the present disclosure provides a computer device, including: a processor, a memory and a bus, wherein the memory stores machine-readable requests executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable request is executed by the processor, a method for parsing streaming data as described in any possible implementation manner described above is performed.

[0066] An embodiment of the present disclosure provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the streaming data parsing method described in any possible implementation manner described above is implemented.

[0067] The streaming data parsing method, device, medium and equipment provided in the embodiments of the present disclosure receive streaming data, and parse the streaming data into at least one line of JSON object string by identifying the line break in the streaming data, and use the JSON object string as the string to be identified; then determine whether the string to be identified already contains a complete JSON object; if the string to be identified does not contain a complete JSON object, based on the next streaming data received, continue to parse the streaming data and splice the parsing result after the string to be identified, return to determine whether the string to be identified contains a complete JSON object, until it is determined that the string to be identified contains a complete JSON object, then extract the complete JSON object from the string to be identified. In this way, parsing errors can be effectively avoided, and the stability and reliability of data processing can be improved.

[0068] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following briefly introduces the drawings required to be cited in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0070] Figure 1 A schematic diagram of a flow chart of a method for analyzing streaming data provided by an embodiment of the present application is shown;

[0071] Figure 2 A schematic diagram of the structure of a streaming data parsing device provided in an embodiment of the present application is shown;

[0072] Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0073] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0074] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0075] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.

[0076] In modern computer networks, streaming data transmission is a common way of data exchange, especially in real-time data processing and big data technology. In many practical applications, such as real-time data streams, log systems, and network communications, data is often transmitted in the form of streams. For example, in an IoT system, a device may continuously send sensor data; or in an online chat application, a server may push chat messages in real time. These data are usually transmitted in JSON format. Due to network latency or transmission efficiency considerations, these JSON objects may be transmitted across multiple responses, and even one response may contain multiple JSON objects, and sometimes even one JSON object may span multiple responses.

[0077] After research, it was found that in the relevant technology, the JSON parsing method has some problems when processing such multi-line JSON object strings, mainly manifested in the inability to parse the data correctly. Specifically, this is because the existing JSON parser assumes that the input data is a single complete JSON object. However, in streaming transmission, the data will be divided into multiple fragments, which may easily cause the parser to be unable to correctly process these fragments and thus unable to correctly parse the data. Therefore, how to improve the accuracy and stability of streaming data parsing has always been a concern of the industry.

[0078] Based on the above research, the streaming data parsing method, device, medium and equipment provided in the embodiments of the present disclosure specifically include: receiving streaming data, and parsing the streaming data into at least one line of JSON object string by identifying the line breaks in the streaming data, and using the JSON object string as the string to be identified; then judging whether the string to be identified already contains a complete JSON object; if the string to be identified does not contain a complete JSON object, based on the next streaming data received, continue to parse the streaming data and splice the parsing result after the string to be identified, return to judge whether the string to be identified contains a complete JSON object, until it is judged that the string to be identified contains a complete JSON object, then extract the complete JSON object from the string to be identified. In this way, parsing errors can be effectively avoided, and the stability and reliability of data processing can be improved.

[0079] To facilitate understanding of the present embodiment, the execution subject of the streaming data parsing method provided in the embodiment of the present disclosure is first introduced in detail. The execution subject of the streaming data parsing method provided in the embodiment of the present disclosure is a computer device. The computer device may be a terminal device or a server. Among them, the terminal device may also be a mobile device, a user terminal, a terminal, a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data and artificial intelligence platforms.

[0080] In other implementations, the streaming data parsing method may also be implemented by a processor calling computer-readable instructions stored in a memory.

[0081] The following is a detailed description of the streaming data analysis method provided in the embodiment of the present application in conjunction with the accompanying drawings. Figure 1 FIG. 1 is a flowchart of a method for parsing streaming data provided by an embodiment of the present disclosure, wherein the method includes the following S101 to S103:

[0082] S101, receiving streaming data, and parsing the streaming data into at least one line of JSON object string by identifying line breaks in the streaming data, and using the JSON object string as a string to be identified.

[0083] It can be understood that streaming data refers to a continuously generated data stream, which is usually generated in a time series manner. Its sources are diverse, and may be sensor data, network transmission data, or log data. For any type of streaming data in a variety of businesses, its basic structure includes business identification and data body. Here, the line break in the streaming data indicates the end of a line of data and marks the data segmentation point.

[0084] Exemplarily, after receiving the streaming data, the service identifier carried by the streaming data is identified to determine the data buffer corresponding to the streaming data, and the data body in the streaming data is stored in the data buffer corresponding to the service identifier. Then, in a first-in, first-out order, a piece of data is taken out from the data buffer, and the data is parsed into at least one line of JSON object string by identifying the line break in the data, wherein JSON is a commonly used data exchange format that represents data in the form of key-value pairs. After obtaining at least one line of JSON object string, the obtained JSON object string is used as a string to be identified and further processed. In this way, by identifying the service identifier of the streaming data and then classifying it, the confusion and errors that may occur when processing the streaming data are reduced, making data processing more accurate and efficient; and by identifying the line break in the streaming data and parsing the JSON object string, it is helpful to correctly identify the data unit in each streaming data, thereby improving the accuracy and completeness of data processing.

[0085] S102, determining whether the character string to be identified contains a complete JSON object.

[0086] It is understandable that the start tag and the end tag in a complete JSON object match each other, so when judging whether the string to be identified contains a complete JSON object, the following (1) to (2) may be included:

[0087] (1) identifying boundary markers in the character string to be identified line by line, wherein the boundary markers include a preset start marker and a preset end marker;

[0088] (2) Based on the boundary mark in the character string to be identified, determine whether the character string to be identified already contains a complete JSON object, wherein a preset start tag and a preset end tag in the complete JSON object match each other.

[0089] Specifically, the boundary markers of the string to be identified are first scanned line by line, and the boundary markers include a preset start marker and a preset end marker, where the preset start marker can be "{", the preset end marker can be "}", or other preset symbol markers, which are not specifically limited here. After scanning the boundary markers of the string to be identified, it is determined whether the preset start marker and the preset end marker in the string to be identified match each other to determine whether the string to be identified already contains a complete JSON object.

[0090] S103, if the string to be identified does not contain a complete JSON object, based on the next stream data received, continue to parse the streaming data and concatenate the parsing result after the string to be identified, return to determine whether the string to be identified contains a complete JSON object, until it is determined that the string to be identified contains a complete JSON object, then extract the complete JSON object from the string to be identified.

[0091] Exemplarily, after the string to be identified does not contain a complete JSON object, continue to take out another stream data in the data buffer in a first-in-first-out order for stream data parsing, and splice the parsing result after the string to be identified, and re-judge the spliced ​​string to be identified to determine whether it contains a complete JSON object. If the spliced ​​string to be identified still does not contain a complete JSON object, it is necessary to continue to take out the next stream data from the data buffer and repeat the above steps until a complete JSON object is found. After the string to be identified contains a complete JSON object, the complete JSON object is extracted, and consumption is performed based on the business type corresponding to the extracted complete JSON object. For example, according to the business type corresponding to the extracted complete JSON object, it is known that the business type corresponding to the object is an alarm event, then the relevant personnel can perform corresponding operations according to the alarm event (such as sending an alarm notification to the operation and maintenance team, etc.); similarly, when the JSON object corresponds to other types of business events, corresponding operations can also be performed according to its business type.

[0092] It is understandable that in order to ensure the consistency of data parsing, after extracting the complete JSON object from the string to be identified, other streaming data in the data buffer should continue to be processed, which may include the following (a) to (b):

[0093] (a) if the string to be identified contains a remaining string after the complete JSON object is extracted, then based on the next stream data received, continue to parse the stream data and concatenate the parsing result after the remaining string to form a new string to be identified;

[0094] (b) If the string to be identified does not contain any remaining string after the complete JSON object is extracted, the streaming data is parsed based on the next stream data received and the parsing result is used as a new string to be identified.

[0095] Specifically, after extracting the complete JSON object, there may be residual strings in the string to be identified, so it is necessary to determine whether there are residual strings in the string to be identified. If the string to be identified still contains residual strings after extracting the complete JSON object, it is necessary to parse the next stream data received, and then splice the parsed result behind the residual string to form a new string to be identified. In this way, it can be ensured that subsequent data is also included in the recognition process, thereby ensuring the consistency and integrity of data stream processing. Correspondingly, if there are no more residual strings in the string to be identified after extracting the complete JSON object, it means that the currently parsed string is already the last part of a complete JSON object, then the next stream data can be continued to be received and processed as a new string to be identified, to ensure that even if the current JSON object is extracted, the subsequent stream data can be parsed and processed coherently.

[0096] Here, in the case where the string to be identified contains a remaining string after the complete JSON object is extracted, when the streaming data is parsed based on the next stream data received and the parsing result is concatenated after the remaining string to form a new string to be identified, the following (I) to (IV) are also included:

[0097] (I) if the character string to be identified contains a remaining character string after the complete JSON object is extracted, identifying the positional relationship between the remaining character string and the complete JSON object;

[0098] (II) If the remaining character strings are all after the complete JSON object, then based on the next piece of streaming data received, continue to parse the streaming data and concatenate the parsing results after the remaining character strings to form a new character string to be identified;

[0099] (III) If the remaining character strings are all located before the complete JSON object, the remaining character strings are deleted, and based on the next piece of streaming data received, the streaming data is continued to be parsed and the parsing result is used as a new character string to be identified;

[0100] (IV) If the portion in the remaining character string is located before the complete JSON object, the remaining character string located before the complete JSON object is deleted, and based on the next streaming data received, the streaming data parsing is continued and the parsing result is concatenated after the remaining character string located after the complete JSON object to form a new character string to be identified.

[0101] It can be understood that when it is determined that the string to be identified still contains remaining strings after the complete JSON object is extracted, since the parsing results of the streaming data need to be spliced ​​after the remaining strings to form a new string to be identified, it is necessary to judge the positional relationship between the remaining strings and the complete JSON object, which can specifically include three situations: the remaining strings are all after the complete JSON object, the remaining strings are all before the complete JSON object, and a part of the remaining strings is before the complete JSON object.

[0102] Specifically, if all the remaining strings are located after the complete JSON object, this means that they are new JOSN object data parts in the current data stream. In this case, it is necessary to splice the parsing results of the streaming data after the remaining strings based on the next streaming data received to form a new string to be identified. In this way, it can be ensured that the new streaming data is correctly incorporated into the object identification process. If all the remaining strings are located before the complete JSON object, it means that they have been judged whether they contain the corresponding complete JSON, and no secondary judgment is required. These remaining strings should be deleted, and based on the next streaming data received, the parsing results are used as new strings to be identified. In this way, irrelevant data that has been processed can be cleared to ensure the effectiveness and accuracy of the parsing process. If the remaining string is partially located before the complete JSON object and partially located after it, it is necessary to delete the part located before the complete JSON object, and splice the parsing result of the next streaming data received to the part located after the complete JSON object in the remaining string. In this way, the data part related to the complete JSON object can be retained, and the new data can be correctly integrated into the string to be identified, ensuring the consistency and accuracy of data parsing. In addition, the remaining deleted strings may be strings that cannot form a complete JOSN object due to loss during streaming data transmission or other reasons. For the streaming data corresponding to the remaining deleted strings, it is necessary to confirm it as problematic streaming data, generate error information based on the problematic streaming data, and send a data retransmission request to the terminal device corresponding to the problematic streaming data. Here, the retransmission request can carry a service identifier or other information related to the streaming data (such as a number to confirm the order or position of the problematic streaming data in the streaming data) so that the streaming data sender can accurately identify and resend the lost data. In this way, problems that may occur in data transmission can be discovered and solved in a timely manner, ensuring the integrity and reliability of the data, while improving the fault tolerance and stability of the system.

[0103] The streaming data parsing method, device, medium and equipment provided in the embodiments of the present disclosure receive streaming data, and parse the streaming data into at least one line of JSON object string by identifying the line break in the streaming data, and use the JSON object string as the string to be identified; then determine whether the string to be identified already contains a complete JSON object; if the string to be identified does not contain a complete JSON object, then based on the next streaming data received, continue to parse the streaming data and splice the parsing result after the string to be identified, return to determine whether the string to be identified contains a complete JSON object, until it is determined that the string to be identified contains a complete JSON object, then extract the complete JSON object from the string to be identified. In this way, by reading line by line and trying to parse it into a JSON object until the parsing is successful, parsing errors of streaming data can be effectively avoided, and the stability and reliability of streaming data processing are improved.

[0104] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0105] Based on the same inventive concept, the embodiments of the present disclosure also provide a streaming data parsing device corresponding to the streaming data parsing method. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to the above-mentioned streaming data parsing method in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0106] Reference Figure 2 FIG. 2 is a schematic diagram of a streaming data parsing device 200 provided in an embodiment of the present disclosure, wherein the device comprises:

[0107] The data parsing module 201 is used to receive streaming data, and parse the streaming data into at least one line of JSON object string by identifying line breaks in the streaming data, and use the JSON object string as a string to be identified;

[0108] The string determination module 202 is used to determine whether the string to be identified contains a complete JSON object;

[0109] The string concatenation module 203 is used to continue streaming data parsing and concatenate the parsing result after the string to be identified if the string to be identified does not contain a complete JSON object based on the next streaming data received, and return to determine whether the string to be identified contains a complete JSON object. When it is determined that the string to be identified contains a complete JSON object, the complete JSON object is extracted from the string to be identified.

[0110] In a possible implementation, the string concatenation module 203 is further used for:

[0111] If the string to be identified contains a remaining string after the complete JSON object is extracted, then based on the next stream data received, continue to parse the stream data and concatenate the parsing result after the remaining string to form a new string to be identified;

[0112] If the string to be identified does not contain any remaining string after the complete JSON object is extracted, the streaming data parsing is continued based on the next stream data received and the parsing result is used as a new string to be identified.

[0113] In a possible implementation, the string concatenation module 203 is further used for:

[0114] If the character string to be identified contains a remaining character string after the complete JSON object is extracted, identifying the positional relationship between the remaining character string and the complete JSON object;

[0115] If the remaining character strings are all after the complete JSON object, then based on the next piece of streaming data received, continue to parse the streaming data and concatenate the parsing results after the remaining character strings to form a new character string to be identified;

[0116] If the remaining character strings are all located before the complete JSON object, the remaining character strings are deleted, and based on the next piece of streaming data received, the streaming data parsing is continued and the parsing result is used as a new character string to be identified;

[0117] If a part of the remaining string is located before the complete JSON object, the remaining string before the complete JSON object is deleted, and based on the next streaming data received, the streaming data parsing is continued and the parsing result is spliced ​​after the remaining string after the complete JSON object to form a new string to be identified.

[0118] In a possible implementation, the string concatenation module 203 is further used for:

[0119] Determine that the streaming data corresponding to the remaining deleted character string is the problematic streaming data, and generate error information based on the problematic streaming data;

[0120] Based on the error information, a data retransmission request is sent to the terminal device corresponding to the problematic streaming data.

[0121] In a possible implementation, the character string determination module 202 is specifically configured to:

[0122] Identify the boundary markers in the character string to be identified line by line, wherein the boundary markers include a preset start marker and a preset end marker;

[0123] Based on the boundary mark in the character string to be identified, it is determined whether the character string to be identified already contains a complete JSON object, wherein a preset start tag and a preset end tag in the complete JSON object match each other.

[0124] In a possible implementation manner, the data parsing module 201 is further used for:

[0125] storing the streaming data in a data buffer;

[0126] Accordingly, the data parsing module 201 is also used for:

[0127] Taking out a piece of streaming data from the data buffer in a first-in-first-out order, and parsing the streaming data into at least one line of JSON object string by identifying a line break character in the streaming data;

[0128] Accordingly, the string concatenation module 203 is also used for:

[0129] If the string to be identified does not contain a complete JSON object, a stream data is taken out from the data buffer in a first-in-first-out order for stream data parsing, and the parsing result is spliced ​​after the string to be identified.

[0130] In a possible implementation manner, the data parsing module 201 is specifically used for:

[0131] Receiving streaming data for any one of a plurality of services, wherein the streaming data includes a service identifier and a data body;

[0132] Accordingly, the data parsing module 201 is also used for:

[0133] Identify the service identifier carried by the streaming data, and store the data body in the streaming data in a data buffer corresponding to the service identifier;

[0134] Accordingly, the string concatenation module 203 is also used for:

[0135] Consume based on the business type corresponding to the extracted complete JSON object.

[0136] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0137] Based on the same technical concept, the embodiment of the present disclosure also provides a computer device. Figure 3 , which is a schematic diagram of the structure of a computer device 300 provided in an embodiment of the present disclosure, including a processor 301, a memory 302, and a bus 303. The memory 302 is used to store execution instructions, including a memory 3021 and an external memory 3022; the memory 3021 is also called an internal memory, which is used to temporarily store the operation data in the processor 301 and the data exchanged with the external memory 3022 such as a hard disk. The processor 301 exchanges data with the external memory 3022 through the memory 3021.

[0138] In the embodiment of the present application, the memory 302 is specifically used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 301. That is, when the computer device 300 is running, the processor 301 communicates with the memory 302 through the bus 303, so that the processor 301 executes the application code stored in the memory 302, and then executes the method described in any of the above embodiments.

[0139] Among them, the memory 302 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.

[0140] The processor 301 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0141] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the computer device 300. In other embodiments of the present application, the computer device 300 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0142] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of parsing the streaming data in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.

[0143] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of parsing the streaming data in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.

[0144] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0145] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0146] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0147] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0148] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk.

[0149] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A method for analyzing streaming data, characterized in that: The method comprises: Receive streaming data, and parse the streaming data into at least one line of JSON object string by identifying line breaks in the streaming data, and use the JSON object string as a string to be identified; Determine whether the string to be identified contains a complete JSON object; If the string to be identified does not contain a complete JSON object, the streaming data parsing will continue based on the next streaming data received and the parsing result will be concatenated after the string to be identified, and the process will return to determine whether the string to be identified contains a complete JSON object. If it is determined that the string to be identified contains a complete JSON object, the complete JSON object will be extracted from the string to be identified.

2. The method according to claim 1, characterized in that After extracting the complete JSON object from the string to be identified, the method further includes: If the string to be identified contains a remaining string after the complete JSON object is extracted, then based on the next stream data received, continue to parse the stream data and concatenate the parsing result after the remaining string to form a new string to be identified; If the string to be identified does not contain any remaining string after the complete JSON object is extracted, the streaming data parsing is continued based on the next stream data received and the parsing result is used as a new string to be identified.

3. The method according to claim 2, characterized in that If the string to be identified contains a remaining string after the complete JSON object is extracted, then based on the next stream data received, continue to parse the stream data and concatenate the parsing result after the remaining string to form a new string to be identified, including: If the character string to be identified contains a remaining character string after the complete JSON object is extracted, identifying the positional relationship between the remaining character string and the complete JSON object; If the remaining character strings are all after the complete JSON object, then based on the next piece of streaming data received, continue to parse the streaming data and concatenate the parsing results after the remaining character strings to form a new character string to be identified; If the remaining character strings are all located before the complete JSON object, the remaining character strings are deleted, and based on the next piece of streaming data received, the streaming data parsing is continued and the parsing result is used as a new character string to be identified; If a part of the remaining string is located before the complete JSON object, the remaining string before the complete JSON object is deleted, and based on the next streaming data received, the streaming data parsing is continued and the parsing result is spliced ​​after the remaining string after the complete JSON object to form a new string to be identified.

4. The method according to claim 3, characterized in that The method further comprises: Determine that the streaming data corresponding to the remaining deleted character string is the problematic streaming data, and generate error information based on the problematic streaming data; Based on the error information, a data retransmission request is sent to the terminal device corresponding to the problematic streaming data.

5. The method according to claim 1, characterized in that The determining whether the to-be-recognized string contains a complete JSON object includes: Identify the boundary markers in the character string to be identified line by line, wherein the boundary markers include a preset start marker and a preset end marker; Based on the boundary mark in the character string to be identified, it is determined whether the character string to be identified already contains a complete JSON object, wherein a preset start tag and a preset end tag in the complete JSON object match each other.

6. The method according to any one of claims 1 to 5, characterized in that After receiving the streaming data, the method further includes: storing the streaming data in a data buffer; Accordingly, the step of parsing the streaming data into at least one line of JSON object string by identifying line breaks in the streaming data includes: Taking out a piece of streaming data from the data buffer in a first-in-first-out order, and parsing the streaming data into at least one line of JSON object string by identifying a line break character in the streaming data; Correspondingly, if the string to be identified does not contain a complete JSON object, then based on the next stream data received, continue to parse the stream data and splice the parsing result after the string to be identified, including: If the string to be identified does not contain a complete JSON object, a stream data is taken out from the data buffer in a first-in-first-out order for stream data parsing, and the parsing result is concatenated after the string to be identified.

7. The method according to claim 5, characterized in that The receiving of streaming data comprises: Receiving streaming data for any one of a plurality of services, wherein the streaming data includes a service identifier and a data body; Accordingly, storing the streaming data in a data buffer includes: Identify the service identifier carried by the streaming data, and store the data body in the streaming data in a data buffer corresponding to the service identifier; Accordingly, after extracting the complete JSON object from the string to be identified, the method further includes: Consume based on the business type corresponding to the extracted complete JSON object.

8. A streaming data parsing device, characterized in that: The device comprises: A data parsing module, used for receiving streaming data, and parsing the streaming data into at least one line of JSON object string by identifying line breaks in the streaming data, and using the JSON object string as a string to be identified; A string determination module is used to determine whether the string to be identified contains a complete JSON object; The string concatenation module is used to continue streaming data parsing and concatenate the parsing result after the string to be identified if the string to be identified does not contain a complete JSON object based on the next streaming data received, and return to determine whether the string to be identified contains a complete JSON object. When it is determined that the string to be identified contains a complete JSON object, the complete JSON object is extracted from the string to be identified.

9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

10. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Real-time processing and displaying method for large-model streaming JSON (JavaScript Object Notation) return result

    CN120162104A

  • Method and system for realizing progressive user interface rendering through real-time completion

    CN121255321A

  • Content parsing method and apparatus, device, and storage medium

    WO2026117995A1