String extraction and splicing method for non-standard JSON large text and electronic device

By employing boundary string positioning and memory slicing iterative overwriting techniques, the problem of parsing large non-standard JSON text was solved, enabling efficient data extraction and splicing, and improving the compatibility and efficiency of heterogeneous data processing.

CN122389818APending Publication Date: 2026-07-14HUAIBEI INST OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAIBEI INST OF TECH
Filing Date
2026-04-17
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing technologies cannot effectively parse and extract target data when faced with large, non-standard JSON text, resulting in formatting failures and preventing automated data retrieval.

Method used

By employing boundary string positioning and memory segmentation iterative overwriting techniques, the target fragments are accurately extracted and dynamically concatenated by identifying local feature patterns in the data, thus bypassing the dependence of standard parsing tools on the complete syntactic structure of the data.

Benefits of technology

In non-standard data environments, robust business information extraction and continuous integration have been achieved, significantly improving the compatibility and processing efficiency of heterogeneous data parsing, and avoiding manual preprocessing and complex logic repair.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122389818A_ABST
    Figure CN122389818A_ABST
Patent Text Reader

Abstract

The application relates to the technical field of data processing, and particularly discloses a string extraction and splicing method for non-standard JSON large texts and electronic equipment, which comprises the following steps: obtaining an original large text string to be processed returned by a business interface, and configuring a starting boundary string and an ending boundary string according to target data extraction requirements; and taking the starting boundary string as a split identifier to perform full-amount split operation on the original large text string to be processed to generate a substring block set. The application combines the technical means of boundary string positioning and memory slice iteration overwriting, effectively bypasses the dependence of a standard analysis tool on a complete syntax structure of data, and in actual application, even if facing a heterogeneous large text stream with a broken syntax or containing redundant information, the scheme only needs to identify local characteristic rules of data arrangement, can accurately strip target fragments from continuous original texts, and performs dynamic splicing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, specifically to a method and electronic device for extracting and concatenating strings from large non-standard JSON text. Background Technology

[0002] In existing application programming interface (API) call scenarios, the data returned by the server is typically presented in string format. Developers generally use standard JSON formatting tools or built-in deserialization functions to convert the received string into a structured object. Using this structured object, developers can read the target data and perform business logic processing based on preset key-value pairs or array indices.

[0003] Standard deserialization mechanisms require that the input string must strictly conform to the syntax specification. When the data returned by the interface contains mismatched parentheses, type nesting conflicts, or non-standard prefixes, the standard parsing tool will cause the formatting operation to fail due to the triggering of a syntax error.

[0004] This situation creates a technical conflict between the mandatory requirements of standard syntax validation and the actual need to extract valid fragments from non-standard data streams, resulting in the inability to automatically acquire target information in scenarios with abnormal data structures. Summary of the Invention

[0005] This invention aims to at least partially address one of the technical problems in related technologies. Therefore, the objective of this invention is to propose a string extraction and concatenation method and electronic device for large non-standard JSON text, thereby improving the compatibility and processing efficiency of heterogeneous data parsing.

[0006] To achieve the above objectives, a first aspect of the present invention proposes a method for string extraction and concatenation of large non-standard JSON text, comprising the following steps:

[0007] Obtain the raw large text string to be processed returned by the business interface, and configure the start boundary string and end boundary string according to the target data extraction requirements;

[0008] Using the starting boundary string as a segmentation identifier, a full segmentation operation is performed on the original large text string to be processed to generate a substring block set, and the target number of loops is determined based on the number of elements in the substring block set;

[0009] Construct the extraction and concatenation loop logic, and initialize the iteration counter and the full result string variable;

[0010] In each iteration of the extraction and splicing loop logic, the following operations are performed sequentially:

[0011] Calculate the first hit position parameter of the starting boundary string in the original large text string to be processed in the current iteration cycle, and determine the effective truncation starting position by combining the static length value of the starting boundary string;

[0012] Using the effective truncation start position as the retrieval offset start position, the first occurrence position of the ending boundary string is retrieved backward to determine the effective truncation end position;

[0013] Extract temporary dynamic substrings based on the effective start position and the effective end position, and append the temporary dynamic substrings to the end of the full result string variable;

[0014] Extract the remaining character fragments from the effective truncation starting position to the end of the original large text string to be processed in the current iteration cycle, use the remaining character fragments to overwrite the original large text string to be processed in the current memory as the processing basis for the next iteration cycle, and increment the iteration counter;

[0015] When the iteration counter equals the target number of iterations, a termination instruction is triggered to exit the extraction and concatenation loop logic, and the full result string variable is output as the final structured parsed text.

[0016] To achieve the above objectives, a second aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein when the computer program is executed by the processor, it implements the steps of the above-described string extraction and concatenation method for non-standard JSON large text.

[0017] To achieve the above objectives, a third aspect of the present invention provides a computer-readable storage medium storing computer control program fragments.

[0018] When the computer control program fragment is read, compiled, and executed by an external microprocessor, it implements the steps of the above-mentioned string extraction and concatenation method for large non-standard JSON text.

[0019] To achieve the above objectives, a fourth aspect of the present invention provides a computer program product, including an underlying computer program architecture package;

[0020] When the computer program architecture package is deployed on any computing node and instantiated, it forces the computing node to execute the above-described steps of the string extraction and concatenation method for non-standard JSON large text.

[0021] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0022] This invention effectively bypasses the reliance of standard parsing tools on the complete syntactic structure of data by employing a combination of boundary string positioning and memory-segmented iterative overwriting. In practical applications, even when faced with heterogeneous large text streams containing broken syntax or redundant information, this solution only needs to identify local feature patterns in the data arrangement to accurately extract target segments from continuous original text and perform dynamic splicing. This process requires no manual preprocessing or complex logical repair of the original text, directly achieving robust extraction and continuous integration of core business information in non-standard data environments, significantly improving the compatibility and processing efficiency of heterogeneous data parsing. Attached Figure Description

[0023] The disclosure of this invention is illustrated with reference to the accompanying drawings. It should be understood that the drawings are for illustrative purposes only and are not intended to limit the scope of protection of this invention. In the drawings, the same reference numerals are used to refer to the same parts. Wherein:

[0024] Figure 1 This is a flowchart illustrating the string extraction and concatenation method for large non-standard JSON text provided by this invention.

[0025] Figure 2 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0026] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0027] The following describes, with reference to the accompanying drawings, a method for string extraction and concatenation of large non-standard JSON text, an electronic device, a computer-readable storage medium, and a computer program product according to embodiments of the present invention.

[0028] Example 1:

[0029] This embodiment provides a string extraction and concatenation method for large non-standard JSON text. In the fields of computer science and low-level data stream processing, this method is typically deployed in electronic devices that perform middleware routing, gateway aggregation, or heterogeneous data cleaning. This electronic device includes a central processing unit (CPU) for executing computational logic, volatile storage elements (such as random access memory, RAM) for data caching and resident storage, and non-volatile storage media for persistent program instructions. After receiving data packets sent by external nodes via the Transmission Control Protocol (TCP), the electronic device reassembles these hashed byte streams into a string structure visible to the business application layer, thus entering the extraction and concatenation execution sequence described in this embodiment.

[0030] Specifically, the method in this embodiment includes the following steps:

[0031] Step 1: Initialize and configure the parameters for receiving and parsing business data.

[0032] Specifically, the gateway receiving module of the electronic device obtains the raw large text string to be processed returned by the business interface, and configures the start boundary string and end boundary string according to the target data extraction requirements. The raw large text string to be processed is non-standard JSON payload data returned by the server, which contains array length out-of-bounds errors or nested syntax errors. In actual network request operation scenarios, due to defects in the concatenation logic of the upstream server data source or data packet truncation during network transmission, the JSON structure obtained by the receiving end is often structurally corrupted. For example, there may be extra commas in the data stream, missing corresponding closing curly braces, or the number of array elements declared inside may exceed the maximum memory allocation threshold supported by the standard deserialization engine, thus manifesting as non-standard JSON payload data. The output full result string variable is used to bypass the standard JSON deserialization verification process and directly provide continuous target text data. The standard JSON deserialization verification process, such as the JSON.parse method built into mainstream programming languages, will first build an abstract syntax tree and perform strict pairing verification when it is executed. Once the above syntax errors are detected, an exception will be thrown immediately and the operation will be interrupted. The solution provided in this embodiment abandons the global verification process of constructing an abstract syntax tree and instead adopts a cursor sliding extraction mechanism based on local features.

[0033] It is also important to note that the start boundary string and the end boundary string are feature anchor data input into system memory by developers or pre-configured scripts. In physical memory, these two boundary strings are encoded as a continuous sequence of bytes. For example, when the target data is descriptive information within a specific log field, the start boundary string can be configured as an identifier sequence containing leading double quotes and a colon, and the end boundary string can be configured as a trailing carriage return or a specific delimiter. During the initialization phase, the system reads these two boundary strings into the CPU's cache to reduce main memory access latency during subsequent high-frequency scan comparisons.

[0034] Step 2: Full partitioning operation and iterative depth calculation.

[0035] Specifically, the system uses the starting boundary string as a segmentation identifier to perform a full segmentation operation on the original large text string to be processed, generating a substring block set, and determines the target number of iterations based on the number of elements in the substring block set. At the underlying implementation level, the full segmentation operation involves the system traversing the original large text string to be processed once, and executing breakpoint markings at the memory offset address where the starting boundary string is matched each time. This logically segments the originally continuous single large memory block into a set of memory pointer mappings for multiple sub-segments; this set is the substring block set.

[0036] Optionally, determining the target number of iterations based on the number of elements in the substring block set specifically includes: statistically obtaining the total number of segmented elements contained in the substring block set, defining it as a first set length value; eliminating redundant computational costs caused by invalid segmentation at the end, and performing a difference operation between the first set length value and the value 1; defining the output result of the difference operation as the target number of iterations to constrain the maximum iteration depth of the extraction and splicing loop logic; wherein, both the first set length value and the target number of iterations are non-negative integers.

[0037] In the above process, the mathematical logic for calculating the target number of iterations can be represented by the following formula:

[0038] ;

[0039] in, Indicates the target number of iterations. Represents the length of the first set, a constant. This indicates the compensation value of the invalid end block that needs to be removed.

[0040] In actual string splitting operations, if the original large text string to be processed actually contains several starting boundary strings, the number of elements in the substring block set generated after full splitting will inevitably be an order of magnitude greater than the actual frequency of occurrence of the starting boundary strings. This extra last block is the residual data segment from the last starting boundary string to the end of the entire text, and this residual data segment does not contain any new starting boundary strings.

[0041] Therefore, by subtracting the value from the above formula The difference operation can calculate the number of effective regions that actually need to be extracted for target information with extremely high precision. Assigning this value to the target loop count can constrain the system to avoid making illegal out-of-bounds memory accesses to the last useless memory region when scheduling loop logic, thus ensuring the program's memory safety and reducing CPU idling power consumption.

[0042] Step 3: Extract and construct the concatenated loop logic and locate the internal addressing.

[0043] The system constructs an extraction and concatenation loop logic and initializes an iteration counter and a full result string variable. During each iteration of the extraction and concatenation loop logic, the following addressing and extraction operations are performed sequentially. The iteration counter is initialized to zero in the system register to monitor the current lifecycle stage of the loop. The full result string variable is allocated the memory address of an empty string object during initialization, serving as the final loading container for all subsequent extracted fragments.

[0044] Specifically, the first hit position parameter of the starting boundary string in the original large text string to be processed in the current iteration cycle is calculated, and the effective truncation start position is determined by combining the static length value of the starting boundary string; using the effective truncation start position as the retrieval offset start point, the first occurrence position of the ending boundary string is retrieved backward to determine the effective truncation end position. The internal positioning steps for determining the effective truncation start position and the effective truncation end position specifically include:

[0045] The algorithm scans the original large text string to be processed in the current iteration cycle using a forward single-pattern matching algorithm, and captures the first pointer position variable that matches the starting boundary string. The value of the first pointer position variable is added to the static length value of the starting boundary string, and the resulting index offset value is used as the effective truncation start position. The search cursor is jumped to the effective truncation start position, and the search cursor is scanned to the right from the search cursor to capture the second pointer position variable that matches the ending boundary string, and the second pointer position variable is used as the effective truncation end position.

[0046] The offset calculation formula used in the above index offset value positioning calculation is as follows:

[0047] ;

[0048] in, This indicates the index offset value of the valid truncation start position. This represents the scalar index of the memory address corresponding to the first pointer position variable. This represents the static length of the starting boundary string. In practical scenarios, forward single-pattern matching algorithms (usually implemented by the system's underlying library, such as naive matching based on character features or...) (Matching) to extract from massive amounts of text Then, the central processing unit processes it. and The system commands perform an addition operation, controlling the retrieval cursor to forcibly skip the physical memory space occupied by the starting boundary string itself, thereby accurately locating the starting byte of the actual business data. This operation ensures that the extracted data originates from... This new coordinate anchor point begins to perform a unidirectional scan to the right (i.e., in the direction of increasing memory address) until it encounters the first byte of the end boundary string, at which point the address index is recorded as the valid end point position.

[0049] Step 4: Abnormal data handling and adaptive safety circuit breaking.

[0050] It is important to note that in real-world heterogeneous network environments, downlink data streams often experience packet loss, leading to the physical truncation of large text characters at the end of transmission. To address this, the process of retrieving the end boundary string from the effective truncation starting position further includes an adaptive protection step to handle non-standard data loss: real-time monitoring of the return status scalar of the backward retrieval operation; if the return status scalar indicates that the end boundary string cannot be matched within the remaining character range, an out-of-bounds safety circuit breaker is triggered; the effective truncation endpoint position is forcibly reset to the text end index of the original large text string to be processed in the current iteration cycle, and the extraction and concatenation loop logic is terminated after forcibly ending the current extraction and concatenation operation.

[0051] When the system performs memory addressing, if the search cursor slides to the last byte of the current text but still fails to read a character structure matching the end boundary string, the underlying matching function will return an invalid status scalar, usually represented by a negative value such as -1 or a specific null pointer exception signal. Once the monitoring process captures this status scalar, it indicates that the currently processed text segment has been physically corrupted. At this point, if the cursor continues to address downwards, it will trigger a memory out-of-bounds access error (Segmentation Fault). The intervention of the out-of-bounds safety circuit breaker logic, by directly anchoring the truncation endpoint to the currently accessible maximum safe memory boundary, i.e., the end index of the text, ensures that even under extreme network truncation conditions, the electronic device can at least safely recover and extract the remaining valid string segments. After the extraction is completed, a termination command is issued to safely exit the entire loop stack, significantly improving the device's disaster recovery capability in high-throughput operations in harsh network environments.

[0052] Step 5: Dynamic cursor splicing and memory capacity suppression control.

[0053] A temporary dynamic substring is extracted based on the effective start and end positions of the extraction, and then appended to the end of the full result string variable. This appending operation employs a dynamic cursor concatenation rule: the current end memory address of the full result string variable is obtained; when allocating contiguous memory blocks, it is determined whether the allocated memory capacity meets the byte size of the temporary dynamic substring; if insufficient, an expansion memory pool is requested according to a preset expansion step coefficient, and after migrating the original data as a whole, the bytes of the temporary dynamic substring are directly pushed after the current end memory address to suppress memory fragmentation caused by high-frequency concatenation.

[0054] The calculation of dynamic memory expansion capacity can be expressed by the following control formula:

[0055] ;

[0056] in, This indicates the total byte capacity of the requested extended memory pool. This represents the currently allocated memory capacity of the string variable representing the full result. This represents the preset expansion step factor, typically a floating-point constant greater than 1, such as 1.5 or 2.0. This indicates the byte size of the currently extracted temporary dynamic substring. The function is used to select the maximum value from the results of the two dimensions as the actual amount of memory requested.

[0057] In practical low-level string operations, string objects in most high-level programming languages ​​are designed to be immutable. If the traditional direct addition operator is used for concatenation, the CPU needs to allocate a new memory region in RAM each time, equal in size to the sum of the original and new strings, then copy the data byte by byte, discarding the old memory. As the number of iterations increases, this operation causes the CPU's time complexity to rise exponentially, while leaving a massive amount of memory fragments in the heap that are difficult for the garbage collector to clean up in a timely manner. This embodiment introduces an expansion step coefficient using the formula described above. .

[0058] When the system detects that the current memory capacity is insufficient to accommodate the newly extracted temporary dynamic substring, it not only requests the currently needed physical space, but also... Instead, it pre-allocates a more generous extended memory pool based on the existing scale in multiples, i.e. If the calculated value of the multiplier is large enough to accommodate the new string, the system uses the larger value for system call allocation. After the original data is copied to the new pool as a whole block, a large amount of blank bytes are reserved after the new tail memory address. When subsequent loops append temporary dynamic substrings, the system can directly push the data into the blank area due to the sufficient reserved capacity, avoiding the overhead of frequent system-level memory allocation calls and copying old data. In high-frequency, large-text loop concatenation scenarios, this mechanism amortizes the time complexity of the concatenation operation to a constant level, resulting in significant system resource savings.

[0059] Step 6: Handle base overwriting and iterative state changes.

[0060] Specifically, the remaining character segments from the effective truncation start position to the end of the original large text string to be processed in the current iteration cycle are extracted. These remaining character segments are then used to overwrite the original large text string to be processed in the current memory as the processing basis for the next iteration cycle, and the iteration counter is incremented. The step of using the remaining character segments to overwrite the original large text string to be processed in the current memory as the processing basis for the next iteration cycle specifically includes: obtaining the upper limit of the overall character length of the original large text string to be processed in the current iteration cycle; using the calculated effective truncation start position as the front-end truncation cursor and the upper limit of the overall character length as the back-end boundary cursor; precisely stripping all continuous byte streams between the front-end truncation cursor and the back-end boundary cursor to form the remaining character segments; and through memory release and reassignment operations, ensuring that the next iteration uses the remaining character segments as the new scanning benchmark.

[0061] In the process of generating the remaining character fragments, the algorithm for data truncation length is as follows:

[0062] ;

[0063] in, This indicates the physical byte length of the generated remaining character fragments. This represents the upper limit of the overall character length of the original large text string to be processed within the current iteration cycle, i.e., the final index limit at the end of the text.

[0064] Through this step, the system essentially completes a truncated reading of the original text. All content from the beginning of the truncation cursor to the end of the text is precisely stripped away. At this point, all data before the truncation cursor (including the starting boundary string that has been successfully matched in this round and the extracted business data) is determined to be invalid data. The resident space occupied by the discarded data is released through explicit memory release instructions, and then the variable pointer is rebound to the generated remaining character fragment. This reassignment operation builds a reduced new processing baseline pool.

[0065] After the iteration counter increments by one, the system will only scan the next starting boundary string within this smaller new slice when the next loop starts. This iterative mechanism of trimming the original text round by round ensures that the scanning addressing space becomes smaller and smaller, preventing the processing speed of later loops from decaying over time. Furthermore, by frequently cleaning up already consumed useless memory segments, the system keeps the memory consumption during peak program execution below a stable level, preventing the memory overflow risk that easily occurs in large text processing.

[0066] Step 7: Trigger the termination command and output the full result.

[0067] When the iteration counter equals the target loop count, a termination instruction is triggered to exit the extraction and concatenation loop logic, and the full result string variable is output as the final structured parsed text. At the end of each iteration, the system clock scheduler checks the current value of the iteration counter against the target loop count stored in the main control register. Once the two values ​​coincide, it indicates that all potential substring blocks evaluated based on the previous full segmentation operation have been processed. The termination instruction triggered at this time forces the program to exit the current iteration loop, releasing various temporary control pointers related to the loop. The final output full result string variable has been assembled into a long text paragraph composed of tightly connected discrete temporary dynamic substrings, and can be sent to the natural language processing engine, front-end rendering component, or stored in a structured database via the standard output interface.

[0068] For example, such as Figure 1As shown, the underlying state machine torsion and data flow process of extracting and splicing loop logic described in this embodiment is explained in a more intuitive and detailed way. The flowchart fully demonstrates the closed-loop control logic from parameter initialization, loop boundary constraints to final result output.

[0069] In actual operation, the specific execution sequence of each node is as follows:

[0070] First, after the system's main thread enters from the "Start" node, it executes the initialization step of "defining several variables for later use." During this stage, the system allocates the necessary register space on the stack, specifically including: initializing the loop iteration counter i (usually set to an initial value of 0), initializing the full result string variable concatenatedStr (initially an empty string) to store the extracted results, and initializing the variable splitArraySum to store the target loop count.

[0071] Subsequently, the system enters the segmentation preprocessing stage, performing the operation of "splitting tobeProcessedStr into an array of substrings using the split method". Here, the system calls the underlying string splitting function, using the starting boundary string startStr as the splitting identifier, to perform a full split on the original large text string to be processed tobeProcessedStr in the current memory, generating a set of substring blocks.

[0072] Next, the operation of "subtracting 1 from the length of the split array and assigning it to splitArraySum" is performed. This step uses mathematical difference calculation to accurately remove invalid segmentation cursors caused by the lack of matching boundaries at the end of the text, calculates the actual number of valid extraction blocks contained in the current text, and assigns this threshold to splitArraySum to strictly constrain the maximum iteration depth of subsequent loop logic.

[0073] After boundary constraints are completed, the system's main control flow enters the core condition judgment node: "Judgment" This node acts as a valve for monitoring the iterative lifecycle, determining whether the extraction operation continues or terminates.

[0074] When the judgment result is "yes", it indicates that there are still unparsed valid data blocks in the current memory. The system then enters the processing branch of a single iteration and performs the following operations in sequence:

[0075] (1) Define variable strTemp="" to open up a temporary cache space for the current loop cycle whose lifespan is limited to this iteration.

[0076] (2) Execute the addressing and extraction action of "at the first occurrence of startStr in tobeProcessedStr, extract the string between startStr and endStr, and assign it to strTemp". The system calculates the starting boundary string. With end boundary string The initial memory offset pointer is used to precisely extract the business characteristic data between the two, forming a temporary dynamic substring, and then... To carry.

[0077] (3) Execute "concatenate strTemp to the end of concatenatedStr". The system adopts a dynamic cursor appending strategy to push the temporary dynamic substring extracted in this round into the memory address at the end of the full result string variable.

[0078] (4) Perform base truncation and overwrite operations: "remove the string between positions 0 and (startStr at the first occurrence of tobeProcessedStr + startStr.length) from tobeProcessedStr". The system generates the remaining character fragment by forcibly releasing the invalid continuous byte stream that has been scanned and processed at the front end, i.e., the preceding data segment including the current start boundary, and directly overwrites the original data with this fragment. The current memory object. This operation significantly reduces the scan base range for the next loop, ensuring the efficiency of unidirectional cursor addressing.

[0079] (5) Execute the step instruction " This increments the loop iteration counter. Then, the control flow jumps back to the "decision" state along the feedback loop. The condition node is set to initiate the next round of state verification.

[0080] When the loop reaches a specific point in time, the state machine is in the "decision" state. When the result at the node is "No", it indicates that all target blocks calculated in the previous step have been accurately extracted. At this time, the system immediately breaks the current closed-loop network and enters the output step of "returning the concatenated string concatenatedStr". The long text data that has been structured and integrated is thrown outward and finally flows to the "end" node, safely destroying the context resources of the current running environment.

[0081] In general, existing common non-standard JSON processing solutions heavily rely on regular expression validation or redundant global string replacement and repair scripts. Using regular expression replacement is prone to severe (or large-scale) backtracking calculations when dealing with large texts of several megabytes in length, leading to CPU blocking; while attempting to use scripts to fix syntax errors and then call the JSON formatting engine again often fails due to the complexity of unknown structures.

[0082] Compared to the existing technologies mentioned above, this embodiment combines a dynamic cursor scanning and positioning mechanism with a memory overwrite and pruning strategy based on iterative reduction principles, specifically eliminating the high cost required for constructing a global abstract syntax tree in large text parsing. The pointer jump calculation revealed in this embodiment bypasses redundant boundary character metadata, and solves the problem of memory fragmentation accumulation caused by high-frequency extraction through parallel collaboration of a hierarchical adaptive expansion strategy and residual data truncation and overwrite logic. This technical solution not only objectively improves the compatibility of handling incomplete data with missing parentheses or out-of-bounds elements, but also constrains the upper limit of memory consumption and improves scheduling efficiency within the actual underlying operation level. This allows the system to have stable target string structure extraction and integration capabilities from heterogeneous data sources with out-of-order or syntactically damaged data without executing redundant format repair logic.

[0083] Example 2:

[0084] In actual business data interaction, the JSON structure returned by the server is often not a flat key-value pair, but rather a complex hierarchical data structure containing nested objects or arrays. When the business requirement is to extract a complete large node from the outermost layer, traditional truncation methods based on matching a single endpoint character will erroneously truncate the data when encountering the same endpoint character in internal child nodes, leading to data structure corruption. Therefore, this embodiment details the execution logic of a depth-penetration retrieval mechanism based on dynamic weight balancing.

[0085] Specifically, the step of scanning to the right from the retrieval cursor to capture the second pointer position variable matching the end boundary string includes: identifying whether the start boundary string and the end boundary string constitute a closed pairing identifier in terms of structural semantics. Here, a closed pairing identifier refers to a combination of characters or strings in computer formal languages ​​and data serialization formats (such as JSON, XML, etc.) that has a clear hierarchical wrapping semantics and must appear in pairs.

[0086] In the memory processing logic of electronic devices, the system has one or more built-in mapping tables. For example, the left curly brace "{" and the right curly brace "}" are mapped to a set of object pairing identifiers, and the left square bracket "[" and the right square bracket "]" are mapped to a set of array pairing identifiers. When the system receives the set start boundary string and end boundary string, the parsing engine extracts the core semantic characters of these two boundary strings and sends them to the mapping table for comparison and lookup.

[0087] Optionally, if it is determined that the closed pairing combination identifier is formed, a nested depth weight balancer is initialized and mounted at the effective truncation start position, and the initial base weight threshold of the nested depth weight balancer is set to the value 1. At the level of computer low-level hardware allocation and operating system task scheduling, the physical essence of the nested depth weight balancer is a dedicated register inside the central processing unit (CPU) of the electronic device, or an integer state variable space allocated in the main memory (RAM) stack area. This balancer is specifically used to record and deduce the logical nesting depth of the current retrieval cursor in real time during complex linear scan processes. Mounting this operation means binding the memory lifecycle of the balancer to the current addressing scan process, ensuring that the value changes of the balancer are not interfered with by other concurrent threads during the scan cycle from the effective truncation start position to the effective truncation end position.

[0088] It is also important to note that setting the initial base weight threshold to 1 is logically necessary. In the steps of Example 1, the system has already found the starting boundary string through forward matching, and the retrieval cursor has crossed this starting boundary string, reaching the effective truncation starting point. This means that, logically, the current retrieval cursor is already within the first level of nested structure opened by the starting boundary string. Therefore, the balancer representing the nesting depth must be initialized to 1 to objectively reflect the logical level state corresponding to the current physical cursor.

[0089] Specifically, using a single byte as the smallest addressing granularity, the retrieval cursor is controlled to perform a bit-by-bit sliding scan operation starting from the effective truncation starting position. When processing large text strings, the data exists in memory as a continuous byte stream, for example, using UTF-8 or ASCII encoding standards. Using a single byte as the smallest addressing granularity requires the underlying instructions to control the memory pointer not to perform coarse jumps based on fixed block sizes (such as 4-byte or 8-byte leaps), but to strictly perform linear address increments with a step size of 1 byte, that is, the cursor address operation is... This high-density bit-by-bit sliding scan mechanism ensures that no control character or pairing symbol is missed in the memory data stream, providing lossless data input for subsequent accurate status verification.

[0090] Optionally, during the bit-by-bit backward sliding scan operation, a bidirectional state machine check is performed: if the current scanned byte matches the starting boundary string, an increment arithmetic operation is performed on the current state value of the nested deep weight balancer; if the current scanned byte matches the ending boundary string, a decrement arithmetic operation is performed on the current state value of the nested deep weight balancer.

[0091] The bidirectional state machine verification process described above is the core operational logic for achieving nested structure penetration in this embodiment. In specific applications, when the retrieval cursor slides bit by bit through the text content, the system extracts the data at the current cursor's memory address every clock cycle and compares it bit by bit with the core features of the known start and end boundary strings. This dynamic arithmetic update process can be represented by the following discrete state transition equation:

[0092] ;

[0093] in, This indicates that after the current clock cycle, the nested depth weight balancer has... Update the state value at any time; Indicates the nested depth weight balancer in The current state value at the time (i.e., the previous cursor position). Indicates in It continuously retrieves the currently scanned bytes read by the cursor. As an indicator function, if and only if When matching the starting boundary string, the output is the value 1; otherwise, it is the value 0. Similarly, As an indicator function, if and only if When the closing boundary string is matched, the output result is the value 1; otherwise, it is the value 0.

[0094] As can be seen from the above state transition equations, when the cursor scans to the child-level starting boundary string inside the data, such as encountering a left curly brace "{" inside a JSON object, it indicates that the data has entered a deeper level of logical nesting. The system then performs an incrementing arithmetic operation, causing... An increase in the value objectively records the deepening of nesting depth. Conversely, when the cursor scans to an inner child "ending boundary string," such as encountering a closing curly brace "}," it indicates that the data has just exited one level of inner logical space, and the system performs a decrementing arithmetic operation, causing... The value decreases.

[0095] It should also be noted that the bit-by-bit backward sliding scan operation and the dynamic arithmetic update of the nested depth weight balancer are continuously executed, and the early truncation instruction generated due to the encounter of the end boundary string in the inner nesting level is forcibly blocked, until the termination condition of strictly decaying the current state value of the nested depth weight balancer to zero is triggered.

[0096] In traditional string manipulation tools, such as the `indexOf` function in JavaScript or the `find` method in Python, the underlying logic is typically hard-coded: once the target endpoint character is first scanned, a truncation instruction is immediately generated and the current index position is returned. This traditional logic is effective when processing parallel structured data, but it can lead to serious data structure corruption when processing non-standard JSON text containing complex hierarchies. For example, when extracting the structure `{"A":{"B":1}}`, if it starts with `{` and ends with `}`, traditional tools will trigger the truncation instruction when scanning the first `}` indicating the end of the inner object `B`, thus extracting an incomplete `{"A":{"B":1}`, losing the final outer closing bracket, causing syntax errors during deserialization in downstream systems.

[0097] This embodiment introduces a control instruction interception and overwriting mechanism. Forced masking means that the system takes over the triggering rights of the truncation logic at the compilation level, separating a single character matching event from the truncation triggering condition. Even if the system detects that the current byte matches the end boundary string, as long as the state machine query shows that the value of the nesting depth weight balancer is not zero, it indicates that the system is currently in an inner nesting level. In this case, the matching event will only trigger a decrementing arithmetic operation, and the system interrupt controller will refuse to issue an early truncation instruction, ordering the cursor to continue sliding forward. This operation ensures that the scanning cursor has the ability to penetrate multiple complex nested regions.

[0098] Only when consecutive decrementing arithmetic operations invert all the bit data in the balancer's internal registers, triggering the strict decay of the current state value of the nested deep weight balancer to zero, will the balancer be triggered to achieve this. When the termination condition of =0 is met, the system recognizes that the current logical level has completely exited the outermost wrapper structure. At this time, the zero-return signal acts as a high-priority hardware or software interrupt source, notifying the addressing engine to stop sliding backward.

[0099] Specifically, the system captures the physical memory offset node where the retrieval cursor is located at the moment the termination condition is triggered, and confirms this physical memory offset node as the true outer boundary point of the ending boundary string. The value of this true outer boundary point is then assigned to the second pointer position variable. At the absolute moment the zero-return termination condition is triggered, the memory address index where the retrieval cursor rests is the final physical boundary of the entire complex nested structure. The physical memory offset node refers to the relative position scale of the byte within the continuous memory space of the original large text string to be processed. The system extracts this relative position scale and identifies it as the true outer boundary point. Subsequently, through an assignment instruction, the value of this true outer boundary point is written into the storage unit of the second pointer position variable pre-allocated by the system. After this, the system can, according to the technical solution described in Embodiment 1, use the calculated first pointer position variable (effectively extracting the starting point position) and the second pointer position variable here (effectively extracting the ending point position) to perform precise memory slicing operations, extracting the complete target string containing all internal complex nested sub-levels.

[0100] Given the current state of technological development, the industry widely relies on regular expressions (Regular Expressions) to handle complex string extraction and data cleaning tasks. However, according to the Chomsky Hierarchy theory in computer science, standard regular expressions are equivalent to Definite Automata (DFA / NFA), which, mathematically, can only handle regular languages ​​and inherently lack the ability to handle context-free grammars with recursive or arbitrary-depth parenthesis structures. This leads to developers having to write extremely verbose regular expressions, prone to catastrophic backtracking (ReDoS vulnerabilities), when attempting to extract deeply nested non-standard JSON nodes using regular expressions. Furthermore, if the nesting level exceeds a preset limit, the extraction process will still fail.

[0101] Compared to the limitations of existing technologies based on regular expressions, the string extraction and concatenation technology based on bidirectional state machine verification disclosed in this embodiment introduces a nested depth weight balancer with stack counting properties within a unidirectional cursor linear addressing framework. This mechanism essentially endows a finite state automaton with the processing capabilities of a pushdown automaton. Through closed-loop logic of initializing basic weights, bit-by-bit scanning, dynamic weight increment / decrement, and strict zero-triggered termination, this scheme unifies the originally conflicting unidirectional nearest-neighbor matching truncation and nested data structure integrity assurance into a linear time complexity algorithm model.

[0102] In practical network operations and maintenance, data crawling and cleaning, and heterogeneous API gateway log parsing, this technical solution has enabled electronic devices to possess extremely stable anti-interference extraction capabilities when faced with non-standard text containing unpredictable nesting depths. The technical feature of forcibly blocking early truncation instructions ensures that even if the original text is filled with data interference items identical to boundary characters, the system can still accurately anchor the true outer boundary. Thus, without needing to repair the original text syntax or load a large and expensive JSON serialization abstract syntax tree, it directly extracts specific string fragments with complete semantics and structure at the memory level, greatly reducing the system's CPU computing power overhead and improving service robustness in non-standard data environments.

[0103] Example 3:

[0104] In practical edge computing gateways or lightweight data cleaning nodes, the internal data volume of non-standard JSON large text often exhibits extreme unpredictability and drastic local fluctuations. For example, when processing mixed business log sequences, the target fragment extracted in the first few dozen iterations may only be a status feedback code with a length of no more than twenty bytes, while a subsequent extraction job may extract a Base64 encoded image text of several megabytes due to abnormal data source structure or load congestion. If electronic devices are forced to use a fixed static expansion step factor to execute a memory appending strategy, it will trigger a scheduling bottleneck in the underlying resources. When the preset step factor is too conservative, when faced with a sudden large string write request, the system will fall into a loop of requests that are exhausted immediately after a small increase in capacity, and will be forced to initiate expansion calls again. This will cause the central processing unit (CPU) to perform massive data copying and migration operations between different physical memory blocks at high frequency, resulting in serious performance loss and service response delay. When the preset step factor is too aggressive, when processing massive concurrent small text parsing requests, the system will pre-lock an excessively large free memory pool for each processing thread, quickly exhausting the available physical memory resources of the server node, and eventually causing a system-level memory overflow (Out of Memory) failure.

[0105] Therefore, this embodiment replaces the step of applying for memory pool expansion according to a preset expansion step coefficient in the previous embodiment with an adaptive expansion prediction step based on volume fluctuation trends, specifically including the following operations:

[0106] Specifically, a sliding observation queue with a fixed limit is initialized within the extraction and splicing loop logic. In the memory address space management of an electronic device's operating system, the sliding observation queue is essentially a linear storage area contiguously allocated by the system kernel in the heap, dedicated to recording numerical scalars. This linear storage area implements a first-in-first-out (FIFO) data replacement mechanism by maintaining two independent offset pointers: a tail pointer indicating the input end and a head pointer indicating the removal end. The fixed limit refers to a clearly defined static upper limit constraint on the number of independent physical slots that the queue can accommodate in parallel. This static upper limit constraint is usually injected by the system's environment configuration file during the initialization startup phase to prevent the observation queue itself from consuming the available memory of the business system without limit during long-term system operation.

[0107] It should be noted that this sliding observation queue does not carry or cache the actual character encoding data of the text to be processed in the business logic. Instead, it is exclusively used to record and retain numerical features that represent the size of the data volume, thereby providing time-series-based data samples for the subsequent adaptive resource allocation engine.

[0108] Optionally, after each extraction of the temporary dynamic substring, the actual byte value of the currently extracted temporary dynamic substring is pushed into the sliding observation queue. The actual byte value is defined here as the total number of bytes actually occupied by the temporary dynamic substring in the underlying hardware storage medium under the specific character set encoding system adopted by the current electronic device, such as UTF-8 variable-length encoding or GBK double-byte encoding. At the absolute moment when the system successfully extracts and generates the temporary dynamic substring based on the start and end boundaries, the main control thread calls the underlying built-in memory volume measurement function to synchronously obtain the actual byte value. The push operation strictly follows the state machine rotation rules of the queue: when it is detected that the number of elements currently resident in the sliding observation queue has not yet triggered the preset fixed limit, the system directly writes the actual byte value into the adjacent free physical address indicated by the tail pointer of the queue and pushes the tail pointer forward one step; when it is detected that the sliding observation queue is in a full-load closed-loop state, the system control flow will forcibly pop and discard the oldest historical byte value pointed to by the head pointer, and at the same time trigger the shift and overwrite of internal elements, and finally fill the newly generated actual byte value into the monitoring window of the queue. This continuously iterating window scrolling mechanism objectively ensures that the queue always maintains the volume data characteristics of several extraction tasks closest to the current running time node, providing accurate data traceability for characterizing the real-time quality attributes of the data flow.

[0109] Specifically, when it is determined that the allocated memory capacity is insufficient to meet the concatenation requirements and an expansion instruction is triggered, the historical byte values ​​within the sliding observation queue are traversed, the absolute value of the difference between adjacent historical byte values ​​is calculated, and the maximum absolute value of the difference is extracted as the volume fluctuation gradient parameter. The moment when the capacity is determined to be insufficient and an expansion instruction is triggered refers to the point in the program execution context where the remaining available blank physical capacity of the contiguous memory block containing the current full result string variable is numerically less than the actual byte value of the latest temporary dynamic substring that is about to be pushed onto the program.

[0110] Because the underlying memory allocator refuses to perform an out-of-bounds overwrite operation, the system's main control thread must suspend subsequent character concatenation instructions and instead wake up the suspended adaptive expansion prediction engine. The prediction engine's probe pointer starts from the logical head of the sliding observation queue and compares adjacent historical byte values ​​one by one according to the chronological order in which the data was recorded.

[0111] It should also be noted that the above process of calculating and extracting the volume fluctuation gradient parameters can be transformed into the following numerical analysis formula within a computer algebra system:

[0112] ;

[0113] In the formula, This represents the final output extracted volume fluctuation gradient parameters after system traversal and calculation; This indicates that in the sliding observation queue, the position at the th The independent historical byte value at each time series tick position; This indicates that in the sliding observation queue, they are sequentially adjacent. Previously, that is, located in the 1st Historical byte values ​​at each time series tick position; This algebraic expression represents the absolute value of the difference in byte size between two consecutive independent fetching operations; The operator instruction system control unit performs multi-way comparison filtering on all generated absolute differences across the entire fixed-quota range of the sliding observation queue, and returns the highest value obtained through the filtering to the prediction engine via the system bus. By calculating the absolute value of the difference and extracting local maxima, the electronic equipment can sensitively and quantitatively capture significant volume jumps that have occurred in the recent data parsing stream.

[0114] if The output value is relatively low, which physically indicates that the recently parsed and extracted business segments are maintained at approximately the same order of magnitude in terms of size, and the data flow shows a high degree of consistency; conversely, if When the value increases to an extremely large scale, it sends a clear warning signal to the underlying resource scheduler, indicating that the external source is currently inputting abnormal block data with a rapidly expanding or highly irregular volume.

[0115] Optionally, an adaptive scaling decision tree model is constructed, and the volume fluctuation gradient parameters are compared and verified with a preset stable fluctuation threshold. This adaptive scaling decision tree model is visualized in the underlying control flow of the electronic device as a set of branch execution instructions containing conditional jump logic. The preset stable fluctuation threshold is a constant scale persistently stored in the system configuration table by maintenance personnel or self-learning components based on the historical business data baseline normally carried by the current server node, after multiple rounds of statistical sampling. This scale defines, from an engineering practice perspective, the highest tolerance limit of the computing system for random jitter of normal data volume. During runtime, the decision tree model reads data indirectly through register addressing. The scalar value is fed into the arithmetic logic unit (ALU) and compared with the steady fluctuation threshold to perform hardware-level size determination. Then, based on the output state of the determination flag, the program counter (PC) is guided to branch to different memory allocation strategies.

[0116] Specifically, if the volume fluctuation gradient parameter is less than or equal to the stable fluctuation threshold, the arithmetic mean of all historical byte values ​​in the sliding observation queue is calculated, and this arithmetic mean is used as the linear memory increment value. The control system then adds to the extended memory pool according to this linear memory increment value. When the output of the comparison circuit confirms that the currently calculated volume fluctuation gradient parameter fails to exceed the stable fluctuation threshold numerically, the decision logic infers that the non-standard JSON large text segment being parsed by the system is in a period of slight fluctuation with a highly regular format and controllable data length fluctuations. Under this steady-state operating scenario, to prevent the system from blindly requesting large-capacity contiguous memory regions from the kernel and causing an unwarranted spike in memory usage, the system executes a linear and smooth space compensation strategy.

[0117] The process of obtaining linear memory increment values ​​uses the following algebraic formula for calculating the mean in statistics:

[0118] ;

[0119] in, This represents the linear memory increment value obtained as the basis for expansion; This represents the total fixed quota established during the initialization of the sliding observation queue; This indicates that the observation exists in the sliding observation queue. The historical byte values ​​recorded in each physical memory slot; numerator of the formula This indicates that the central processing unit calls the adder to perform a traversal and cumulative summation operation on all valid historical byte values ​​remaining in the queue.

[0120] After obtaining this incremental benchmark, the system formally initiates a request to the operating system kernel to expand the memory pool through a system call service routine. The total target capacity requested is calculated and determined using the following linear combination relationship:

[0121] ;

[0122] In the formula, This represents the total target byte capacity that the system expects to obtain when requesting an expanded memory pool under a linear append strategy in a steady-state environment. This represents the scalar amount of memory bytes that the full result string variable has substantially filled and occupied in the physical device during the current execution cycle; The linear memory increment value generated for performing the arithmetic operations of the previous stage; A linear safety margin multiplier is used to provide a small buffer of space on top of the average. Through this linear control mechanism, each triggered system memory expansion operation only requests enough physical space from the operating system kernel to maintain the recent average additional consumption level a few times. This achieves extremely frugal and precise scheduling of host physical memory resources, thus ensuring the stable operation of high-concurrency parsing threads while maintaining a long-term low level of overall server memory allocation.

[0123] It is important to note that if the volume fluctuation gradient parameter is greater than the stable fluctuation threshold, the latest byte value in the sliding observation queue is extracted as the base multiplier, and the extended memory pool is requested exponentially to eliminate the performance loss caused by repeated memory migration and copying due to fixed-coefficient expansion. When the adaptive expansion decision tree model detects that the calculated volume fluctuation gradient parameter has fallen below the warning line of the stable fluctuation threshold, the system state machine immediately determines that the current character parsing job has entered a period of sudden large data extraction with high resource consumption. At this time, continuing to rely on the aforementioned linear smoothing strategy will have serious negative effects: due to the abnormally large size of the newly generated temporary dynamic substring, any finite linear space added based on the historical average will be quickly exhausted, causing the system to be forced to frequently request larger available fragments from the kernel within a few machine loops, and to repeatedly perform cross-region data migration of the original large string in the limited address space. This will not only block CPU resources for a long time, but also cause a significant drop in the throughput of the parsing service.

[0124] To effectively avoid such performance-degrading loops, the system logic is forced to jump to the exponential allocation strategy branch. The control capacity model for requesting expanded memory pools in exponential multiples is constructed using the following equation:

[0125] ;

[0126] In the above expansion model, The total byte capacity of the exponentially expanded target requested by the system to cope with extreme fluctuation scenarios is clearly defined; This represents the exponential multiplication level parameter embedded in the underlying security policy, and it must be a strict non-negative integer type.

[0127] In this anomaly response branch, the system control unit directly abandoned the conventional approach of proportionally scaling up the existing total capacity base, and instead focused on the direct cause of this space depletion—namely, the extremely large new byte value that triggered the fluctuation. The system uses this enormous value as an independent base, and performs multiplication by an exponential coefficient. The shift amplification operation submits a request for a massive, contiguous memory address space with strong predictive capabilities to the underlying operating system in one go. Thanks to this engineering approach of trading space for execution time, even if subsequent large, malformed blocks of data of similar size are continuously extracted from the large text stream, this massive extended memory pool, pre-constructed according to predictive rules, can readily absorb new data streams in numerous subsequent concatenation loop nodes. This avoids the high clock cycles required for repeatedly allocating large contiguous memory segments and moving massive amounts of underlying byte sequences from the execution flow level.

[0128] In general, existing low-level string manipulation libraries primarily rely on native language-defined mutable string builder classes, such as the StringBuilder architecture in Java or the std::string implementation in C++, to handle high-frequency concatenation requirements. However, the default memory growth curves of existing technologies mostly employ rigid preset mechanisms (such as mechanically expanding to twice the original capacity plus a fixed constant size when the capacity is insufficient). This static scaling logic can barely handle standard JSON data with highly uniform formats, but once it enters application scenarios with extremely volatile data, such as heterogeneous log aggregation in the Internet of Things or the reorganization of non-standard crawler data, it will cause uncontrollable system consumption.

[0129] Compared to existing mechanical expansion techniques, the comprehensive memory adaptive control scheme provided in this embodiment, by integrating a time-series sliding observation mechanism and a local extremum inference algorithm, enables the extraction program to dynamically sense the pulse of external data. When faced with the extraction of continuous small-volume information, the system employs a linear damping algorithm to strictly constrain the upper limit of memory consumption, avoiding server downtime caused by massive concurrent processes competing for physical memory. When encountering abnormal nodes with a sudden surge in data volume, the system can complete millisecond-level strategy switching through a decision tree, initiating an exponential spatial pre-support response based on the latest volume benchmark, objectively eliminating the minor blocking accumulation effect caused by frequent system-level call allocation and memory copying operations. This organic combination of adaptive expansion and contraction objectively and significantly improves the computational robustness and memory asset operation efficiency of electronic devices when performing tasks involving non-standard JSON large text cleaning and extraction.

[0130] Example 4:

[0131] Corresponding to the above embodiments, the present invention also proposes an electronic device.

[0132] like Figure 2 The diagram shows a structural schematic of an electronic device according to the present invention. The electronic device 100 includes a processor 101 and a memory 103. The processor 101 and the memory 103 are connected, for example, via a bus 102. Optionally, the electronic device 100 may further include a transceiver 104. It should be noted that in practical applications, the transceiver 104 is not limited to one unit, and the structure of this electronic device 100 does not constitute a limitation on the embodiments of the present invention.

[0133] Processor 101 may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA, or other programmable logic device, transistor logic device, hardware component, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in connection with this disclosure. Processor 101 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0134] Bus 102 may include a pathway for transmitting information between the aforementioned components. Bus 102 may be a PCI bus or an EISA bus, etc. Bus 102 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 2 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0135] The memory 103 stores a computer program corresponding to the string extraction and concatenation method for non-standard JSON large text in the above embodiments of the present invention. This computer program is controlled and executed by the processor 101. The processor 101 executes the computer program stored in the memory 103 to implement the content shown in the foregoing method embodiments.

[0136] Among them, electronic devices 100 include, but are not limited to: mobile terminals such as laptops and PADs (tablet computers) and fixed terminals such as desktop computers. Figure 2 The electronic device 100 shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of the present invention.

[0137] Example 5:

[0138] Corresponding to the above embodiments, the present invention also proposes a computer-readable storage medium storing computer control program fragments.

[0139] When the computer control program fragment is read, compiled, and executed by an external microprocessor, it implements the steps of the above-mentioned string extraction and concatenation method for large non-standard JSON text.

[0140] Example 6:

[0141] Corresponding to the above embodiments, the present invention also proposes a computer program product, including an underlying computer program architecture package;

[0142] When the computer program architecture package is deployed on any computing node and instantiated, it forces the computing node to execute the above-described steps of the string extraction and concatenation method for non-standard JSON large text.

[0143] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A method for extracting and concatenating strings from large non-standard JSON text files, characterized in that: Includes the following steps: Obtain the raw large text string to be processed returned by the business interface, and configure the start boundary string and end boundary string according to the target data extraction requirements; Using the starting boundary string as a segmentation identifier, a full segmentation operation is performed on the original large text string to be processed to generate a substring block set, and the target number of loops is determined based on the number of elements in the substring block set; Construct the extraction and concatenation loop logic, and initialize the iteration counter and the full result string variable; In each iteration of the extraction and splicing loop logic, the following operations are performed sequentially: Calculate the first hit position parameter of the starting boundary string in the original large text string to be processed in the current iteration cycle, and determine the effective truncation starting position by combining the static length value of the starting boundary string; Using the effective truncation start position as the retrieval offset start position, the first occurrence position of the ending boundary string is retrieved backward to determine the effective truncation end position; Extract temporary dynamic substrings based on the effective start position and the effective end position, and append the temporary dynamic substrings to the end of the full result string variable; Extract the remaining character fragments from the effective truncation starting position to the end of the original large text string to be processed in the current iteration cycle, use the remaining character fragments to overwrite the original large text string to be processed in the current memory as the processing basis for the next iteration cycle, and increment the iteration counter; When the iteration counter equals the target number of iterations, a termination instruction is triggered to exit the extraction and concatenation loop logic, and the full result string variable is output as the final structured parsed text.

2. The method according to claim 1, characterized in that, Determining the target loop count based on the number of elements in the substring block set specifically includes: The total number of segmented elements contained in the substring block set is counted and defined as the length value of the first set; After eliminating redundant computational costs caused by invalid end segments, the length value of the first set is compared with the value 1. The output of the difference operation is defined as the target number of loops to constrain the maximum iteration depth of the extraction and splicing loop logic; Wherein, the length of the first set and the target number of loops are both non-negative integers.

3. The method according to claim 1, characterized in that, The internal positioning steps for determining the effective starting point position and the effective ending point position include: The original large text string to be processed in the current iteration cycle is scanned by a positive single-pattern matching algorithm, and the first pointer position variable matching the starting boundary string is captured. The value of the first pointer position variable is added to the static length value of the starting boundary string, and the resulting index offset value is used as the effective truncation starting position. The search cursor is moved to the effective start point position, and the search cursor is scanned to the right to capture the second pointer position variable that matches the end boundary string, and the second pointer position variable is used as the effective end point position.

4. The method according to claim 3, characterized in that, The step of using the remaining character fragments to overwrite the original large text string to be processed in the current memory as the processing basis for the next iteration cycle specifically includes: Get the upper limit of the total character length of the original large text string to be processed in the current iteration cycle; The calculated effective truncation start position is used as the front-end truncation cursor, and the upper limit value of the overall character length is used as the back-end boundary cursor; The remaining character slice is formed by precisely stripping all continuous byte streams between the front-end truncated cursor and the back-end boundary cursor, and then using memory release and reassignment operations to make the remaining character slice the new scanning reference for the next iteration loop.

5. The method according to claim 1, characterized in that, The process of retrieving the ending boundary string from the effective truncation starting position further includes an adaptive protection step to address non-standard data loss: Real-time monitoring of the return status scalar of backward retrieval operations; If the returned status scalar indicates that the end boundary string cannot be matched within the remaining character range, the out-of-bounds safety circuit breaker logic is triggered. The effective truncation endpoint position is forcibly reset to the text end index of the original large text string to be processed in the current iteration cycle, and the extraction and splicing loop logic is terminated after the current extraction and splicing operation is forcibly ended.

6. The method according to claim 1, characterized in that, The operation of appending the temporary dynamic substring to the end of the full result string variable is performed using dynamic cursor concatenation rules: Get the current end memory address of the full result string variable; When allocating contiguous memory blocks, determine whether the allocated memory capacity meets the byte size of the temporary dynamic substring; If the capacity is determined to be insufficient, an expansion memory pool is requested according to the preset expansion step coefficient. After the original data is migrated as a whole, the byte data of the temporary dynamic substring is directly pushed after the current tail memory address to suppress memory fragmentation caused by high-frequency splicing.

7. The method according to any one of claims 1 to 6, characterized in that, The raw large text string to be processed is non-standard JSON payload data returned by the server that contains array length out-of-bounds errors or nested syntax errors; The output full result string variable is used to bypass the standard JSON deserialization verification process and directly provide continuous target text data.

8. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored on the memory, which, when executed by the processor, implements the steps of the string extraction and concatenation method for non-standard JSON large text as described in any one of claims 1 to 7.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a fragment of a computer control program. When the computer control program fragment is read, compiled and executed by an external microprocessor, it implements the steps of the string extraction and concatenation method for non-standard JSON large text as described in any one of claims 1 to 7.

10. A computer program product, characterized in that: Includes the underlying computer program architecture package; When the computer program architecture package is deployed on any computing node and instantiated, the computing node is forced to perform the steps of the string extraction and concatenation method for non-standard JSON large text as described in any one of claims 1 to 7.