Real-time monitoring method and system for JSON (JavaScript Object Notation) analysis process based on Swift Codable protocol

By implanting probe code in the JSON decoding container to record and generate structured JSON parsing error reports, the problem of missing error path information in the JSON parsing process in the existing technology is solved, and accurate positioning and efficient debugging of JSON nested structures are achieved.

CN120803889APending Publication Date: 2025-10-17SHANGHAI SHENGTENG DATA CO LTD +3
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510793841.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-13
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

The existing JSON parsing process based on the Swift Codable protocol cannot provide detailed error path information when encountering an exception, making it difficult to locate the error field. Especially in complex JSON nested structures, it is difficult for developers to accurately locate the error field.

Method used

Probe code is implanted in the JSON decoding container to record the decoding process of each JSON field, generate a log unit containing the full path, decoding exception type, and original value, and classify it into the log container to generate a structured JSON parsing error report.

Benefits of technology

It implements fine-grained tracking of JSON nested structures and structured error reporting, significantly improving the accuracy of error location and debugging efficiency. It is particularly suitable for complex JSON data parsing scenarios and reduces development and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120803889A_ABST
    Figure CN120803889A_ABST
Patent Text Reader

Abstract

The invention discloses a real-time monitoring method for a JSON (JavaScript Object Notation) analysis process based on a Swift Code protocol. The method comprises the following steps: S1, implanting a probe code for monitoring and recording a decoding process of each JSON field into a JSON decoding container; and when the decoding of the JSON field fails, the probe code records the complete decoding path, the decoding exception type and the original value of the JSON field. S2, in the JSON data analysis process, the probe code records analysis error information of each JSON field with analysis errors, and a log unit is generated; and classifying the plurality of log units into a log container. And S3, generating a structured JSON analysis error report according to the log unit and the log container. According to the method and the device, fine tracking and structured error report of the JSON nested structure data analysis process are realized, and the error positioning accuracy and the debugging efficiency are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to a computer data analysis technology, in particular to a JSON data analysis monitoring method. BACKGROUND

[0002] Swift is a programming language released by Apple. Codable is a protocol in Swift, which is used to realize the mutual conversion between Swift data types and external data (such as JSON, XML, binary, etc.). The Codable protocol includes: the Encodable protocol for converting Swift data into other format data, and the Decodable protocol for converting external data into Swift data types.

[0003] The process of converting JSON (JavaScript Object Notation) format data into Swift data by using Swift Codable protocol is called JSON data analysis, which is also called JSON parsing. Class and struct are two types in Swift. The instance of Swift class is usually called Swift object. The instance of Swift struct can also be generally called Swift object. Swift object is used to carry the result of JSON data analysis.

[0004] JSON object is an unordered collection of key-value pairs. A key-value pair is called a JSON field. The key is a string. The value can be of any type, including JSON object and JSON array. JSON object is enclosed in a pair of curly braces {}, and the key and value are separated by a colon, and the key-value pairs are separated by a comma.

[0005] JSON array is an ordered collection of values. Each value can be of any type, including JSON object and JSON array. JSON array is enclosed in a pair of square brackets [], and the values are separated by a comma.

[0006] JSON nested structure refers to the JSON data containing multiple layers of JSON object or JSON array structure. Example one is given below.

[0007]

[0008] In the above example one, the outermost pair of braces is the first JSON object, the value corresponding to the key user (the middle pair of braces) is the second JSON object, and the value corresponding to the key profile (the innermost pair of braces) is the third JSON object. The third JSON object is nested in the second JSON object, and the second JSON object is nested in the first JSON object, forming a JSON nested structure.

[0009] The existing JSON parsing scheme based on the Swift Codable protocol has the following disadvantages.

[0010] First, when an exception occurs during JSON parsing, such as missing keys, null values, type mismatches, etc., only a simple error message with a fixed format, simple structure, and limited content is returned. Although the error message indicates the error field, it is only displayed in text form and does not have a structured hierarchy; it lacks context information such as original values, expected types, and the JSON object it belongs to.

[0011] Second, the Codable path information (codingPath) is only available when an error is thrown, and it is easily covered or ignored when the nesting level of JSON data is deep. In the case of complex JSON nested structures (such as JSON arrays nested in JSON objects, JSON objects nested in JSON arrays, etc.), it is difficult for developers to reproduce the complete JSON parsing path, making the debugging and locating exception process tedious and inefficient. Example two is as follows.

[0012]

[0013] In the above JSON nested structure, when parsing the age field of the first user (id 1) fails, Codable only provides the error field age, but cannot explicitly indicate: which array element is wrong; which JSON object does it belong to; and what is the error value. Developers must rely on breakpoints, printing, assumptions, and other methods to speculate, which is time-consuming and prone to errors.

[0014] In summary, the existing JSON parsing process based on the Swift Codable protocol runs as a black box and cannot track the parsing status of each field in the JSON nested structure in detail. When an exception occurs, only the top-level error is given, and the path description of the error field is lacking, making it difficult to locate. SUMMARY

[0015] The technical problem to be solved by the present application is: how to monitor the JSON parsing process based on the Swift Codable protocol in real time. For the parsing of complex JSON nested structures, how to accurately locate the error fields in the JSON nested structure and output structured error information containing the complete path.

[0016] To solve the above technical problems, the present application proposes a JSON parsing process real-time monitoring method based on the Swift Codable protocol, including the following steps. Step S1: implanting a probe code for listening to and recording the decoding process of each JSON field in the JSON decoding container; whenever a JSON field decoding fails, the probe code records the complete decoding path of the JSON field, the decoding exception type, and the original value. Step S2: During the JSON data parsing process, the probe code records the parsing error information of each JSON field that has parsing errors, generates a log unit; classify multiple log units into a log container. Step S3: generate a structured JSON parsing error report according to the log unit and the log container.

[0017] Further, the step S1 specifically includes the following sub-steps. Step S11: rewrite the JSON parser to realize the listening and recording of the entire JSON parsing process. Step S12: encapsulate or proxy the standard JSON decoding container and implant the probe code therein; the probe code listens to and records the decoding process of each JSON field, specifically intercepts the decoding call of each JSON field; whenever a JSON field decoding fails, the probe code records the complete decoding path of the JSON field, the type of decoding exception of the JSON field, and the original value of the JSON field.

[0018] Further, in the step S11, the technical means of rewriting is subclassing or wrapping class.

[0019] Further, in the step S12, if the decoding failed JSON field is in a JSON array, the probe code records the array index position of the JSON field; if the decoding failed JSON field is in a JSON object, the probe code records the path of the JSON field in the JSON object.

[0020] Furthermore, in step S12, the probe code is used to identify at least three types of decoding exceptions: missing key, empty value, and type mismatch; missing key refers to the lack of a field in the JSON data, while the corresponding field in the Swift data is a non-optional type, resulting in decoding failure; empty value refers to the existence of a field in the JSON data but the value is empty, while the corresponding field in the Swift data is a non-optional type, resulting in decoding failure; type mismatch refers to the inconsistency between the type of the field in the JSON data and the type declared for the corresponding field in the Swift data, resulting in a decoding error.

[0021] Furthermore, step S2 specifically includes the following sub-steps. Step S21: When the JSON parser parses JSON data, the probe code in the JSON decoding container records the complete decoding path, decoding exception type, and original value of the JSON field where decoding failed, which are collectively referred to as the parsing error information of the JSON field; the complete decoding path includes the array index position and object path of the JSON field where decoding failed, and can uniquely locate the JSON field where decoding failed from the root node. Step S22: Generate a log unit for the parsing error information of each JSON field; the log unit refers to a single record containing the complete decoding path, decoding exception type, and original value of the JSON field; the number of log units is equal to the number of JSON fields where decoding failed. Step S23: Group different log units according to the complete decoding path and nesting level of the corresponding JSON field, and classify them into log containers; log units with different levels of the complete decoding path are classified into different log containers; log units with the same levels of the complete decoding path are classified into the same log container, and log units of different levels are classified into different log containers.

[0022] Furthermore, in step S21, the decoding path codingPath of the decoder Decoder in the Swift standard library is monitored in the decoding process, and the codingPath stack structure is dynamically maintained; when encountering a nested JSON object or JSON array, the current field name or array index is automatically pushed into the codingPath stack to construct a complete decoding path from the root node to the current JSON field.

[0023] Further, the step S3 specifically comprises the following sub-steps. Step S31: removing repeated log units and empty log containers. Step S32: aligning the length of the field names of the log units. Step S33: sorting the fields in the log units according to the field names. Step S34: sorting the log containers according to the key names of the log containers. Step S35: generating the description information of each log container according to the content in each log container; the description information of the log container adopts an indented structure, but only the partial parsing path corresponding to the log container. Step S36: summarizing the description information of all the log containers into a complete JSON parsing error report; the JSON parsing error report adopts an indented hierarchical structure, and records the complete decoding path of the JSON field where the parsing error occurs.

[0024] Further, in the step S31, for the error log units corresponding to the array elements of the same structure but different positions, they are the same except for the array subscript; an index mark is introduced to remove the error log units corresponding to the array elements that are only different in the array subscript, and only the error log unit corresponding to the complete first array element is retained, and the error log units corresponding to the remaining array elements only include the index number and delete the remaining content.

[0025] The application also proposes a JSON parsing process real-time monitoring system based on the Swift Codable protocol, comprising a probe code implanting unit, a parsing error recording unit and a parsing report generating unit. The probe code implanting unit is used for implanting probe code for listening to and recording the decoding process of each JSON field in the JSON decoding container; whenever a JSON field decoding fails, the probe code records the complete decoding path, decoding exception type and original value of the JSON field. The parsing error recording unit is used for recording the parsing error information of each JSON field where the parsing error occurs by the probe code during the JSON data parsing process, generating log units; and classifying multiple log units into log containers. The parsing report generating unit is used for generating a structured JSON parsing error report according to the log units and the log containers.

[0026] The application achieves the technical effects of: realizing fine tracking and structured error reporting of the JSON nested structure data parsing process, and significantly improving the accuracy of error positioning and the debugging efficiency. The application uses the innovative technical means of inserting probe code, recording complete decoding paths and classifying logs, and is particularly suitable for complex JSON data parsing scenarios, and can effectively reduce the development and maintenance costs. BRIEF DESCRIPTION OF DRAWINGS

[0027] Figure 1is the flowchart of the JSON parsing process real-time monitoring method based on the Swift Codable protocol of the present application.

[0028] Figure 2 is Figure 1 is the specific flowchart of step S1 in the present application.

[0029] Figure 3 is Figure 1 is the specific flowchart of step S2 in the present application.

[0030] Figure 4 is Figure 1 is the specific flowchart of step S3 in the present application.

[0031] Figure 5 is the structural diagram of the JSON parsing process real-time monitoring system based on the Swift Codable protocol of the present application.

[0032] In the figure, the reference signs are explained: probe code implanting unit 1, parsing error recording unit 2, parsing report generating unit 3. DETAILED DESCRIPTION

[0033] Please refer to Figure 1 The JSON parsing process real-time monitoring method based on the Swift Codable protocol of the present application includes the following steps.

[0034] Step S1: implanting a probe code for listening to and recording the decoding process of each JSON field in the JSON decoding container. Whenever a JSON field decoding fails, the probe code records the complete decoding path of the JSON field, the decoding exception type, and the original value.

[0035] Step S2: in the JSON data parsing process, the probe code records the parsing error information of each JSON field with parsing error, and generates a log unit. Multiple log units are classified into a log container.

[0036] Step S3: generating a structured JSON parsing error report according to the log unit and the log container.

[0037] Please refer to Figure 2 The step S1 specifically includes the following sub-steps.

[0038] Step S11: Override the JSON parser to take over the whole JSON parsing process. The original JSON parser refers to the JSONDecoder in Swift and its underlying decoding logic components. The technical means of overriding is subclassing or wrapper class. The overridden JSON parser implements the monitoring and recording of the whole JSON parsing process.

[0039] Step S12: Package or proxy the standard JSON decoding container and implant the probe code in it. The standard JSON decoding container in Swift includes KeyedDecodingContaine and UnkeyedDecodingContainer, which are responsible for reading JSON data by key or index and converting it into corresponding Swift data. In order to achieve field-level tracking and monitoring, this step inserts probe code into the decoding (reading and conversion) process of each JSON field by packaging or proxying the standard JSON decoding container interface, listens to and records the decoding process of each JSON field. The probe code is used to intercept the decoding call of each JSON field, and whenever a JSON field decoding fails, it records the complete decoding path of the JSON field, the type of decoding exception of the JSON field, and the original value of the JSON field.

[0040] If the decoding failed JSON field is in the JSON array, the probe code records the exact array index position of the JSON field (tracks to the specific array element through codingPath). If the decoding failed JSON field is in the JSON object, the probe code records the exact path of the JSON field in the JSON object. If the decoding failed JSON field is in the JSON array, and the JSON array is in the JSON object, that is, the decoding failed JSON field is in the JSON nested structure, the probe code records the exact path of the JSON array in the JSON object, and also records the exact array index position of the JSON field in the JSON array. If the decoding failed JSON field is in the second JSON object, and the second JSON object is in the first JSON object, that is, the decoding failed JSON field is in the JSON nested structure, the probe code records the exact path of the second JSON object in the first JSON object, and also records the exact path of the JSON field in the second JSON object.

[0041] The probe code is used to identify at least three types of decoding exceptions: key not found, null value, and type mismatch. Key not found refers to the absence of a field in JSON data, while the corresponding field in Swift data is of a non-optional type, resulting in decoding failure. Null value refers to the presence of a field in JSON data, but the value is null, while the corresponding field in Swift data is of a non-optional type, resulting in decoding failure. Type mismatch refers to the inconsistency between the type of a field in JSON data and the type declared for the corresponding field in Swift data, resulting in decoding error; for example, decoding a string type field in JSON data as an integer type field in Swift data.

[0042] The probe code used in the existing computer field is usually inserted into the application layer logic or module level code in the form of log printing or performance monitoring, and is used to record the running state, exception information, etc. of the key function. Such probe code often has the following shortcomings: it is difficult to accurately locate the specific data field where the error occurs; it generally only monitors function calls or module flows, and cannot deeply embed the field-by-field parsing process of nested data; the error information is mostly text logs, lacking structured and path information, resulting in low debugging efficiency; it lacks support for nested complex data structures, and cannot automatically track the nested path where the error occurs.

[0043] The probe code proposed in the present application, which is different from traditional log-type or callback-type probe code, records the field-level JSON decoding path and decoding exception types, original values, etc., and realizes a non-invasive, structured, and persistent JSON parsing exception monitoring mechanism. This probe code not only supports seamless integration of the Swift Codable protocol, but also can establish a complete behavior record and error tracking link for each JSON data parsing operation without modifying the Swift model or changing the interface calling method, solving the problems of exception information fragmentation, path loss, and context loss in the prior art.

[0044] Please refer to Figure 3 , the step S2 specifically comprises the following sub-steps.

[0045] Step S21: When the JSON parser parses the JSON data, the probe code in the JSON decoding container records the complete decoding path of the JSON field where decoding failure occurs, the decoding exception type, and the original value, collectively referred to as the parsing error information of the JSON field. The complete decoding path includes the array index position and object path of the JSON field where decoding failure occurs, and can uniquely locate the JSON field where decoding failure occurs from the root node.

[0046] For example, in this step, by monitoring the codingPath of Decoder in Swift standard library in the decoding process, and dynamically maintaining the codingPath stack structure, the context information of each level and each field in the JSON data is recorded. When encountering a nested JSON object or JSON array, the current field name (i.e. object path) or array index is automatically pushed into the codingPath stack to build a complete decoding path from the root node to the current JSON field. The probe code reads the complete decoding path information at each JSON field decoding and records it to achieve accurate tracking of the parsing process of any field in the JSON data. The following gives an example three.

[0047]

[0048]

[0049] When parsing the above JSON nested structure, the value "www.email.com" of the phone field cannot be converted to an integer type, resulting in a type mismatch parsing error. At this time, the complete decoding path of the phone field where the parsing error occurs, user.profile.contact.phone, as well as the parsing error type of the JSON field, "type mismatch", and the content of the JSON field, "www.email.com", are recorded.

[0050] Step S22: Generate a log unit for each JSON field parsing error information. The log unit refers to a single record containing the complete decoding path of the JSON field, the decoding exception type, and the original value. The number of JSON fields that have decoding failures is how many log units are generated.

[0051] Step S23: Group different log units according to the complete decoding path and nested level of the corresponding JSON field, and classify them into log containers. Log units with different levels of complete decoding paths are classified into different log containers. Log units with the same level of complete decoding paths are classified into the same log container, and log units with different levels of complete decoding paths are classified into different log containers.

[0052] Still following the above example three, example three contains four pairs of curly braces, corresponding to four JSON objects nested in each other. Assume that from outside to inside are the first JSON object, the second JSON object, the third JSON object, and the fourth JSON object, respectively. The log units of the failed-to-decode JSON fields appearing inside the fourth JSON object are classified into one log container. The log units of the failed-to-decode JSON fields appearing inside the third JSON object and outside the fourth JSON object are classified into another log container. The log units of the failed-to-decode JSON fields appearing inside the second JSON object and outside the third JSON object are classified into another log container. The log units of the failed-to-decode JSON fields appearing inside the first JSON object and outside the second JSON object are classified into another log container. Such hierarchical classification of log containers can more clearly present the location and context relationship of the failed-to-decode JSON fields.

[0053] Referring to Figure 4 , the step S3 specifically comprises the following sub-steps.

[0054] Step S31: removing duplicate log units and empty log containers.

[0055] When parsing JSON nested structures (especially JSON arrays), we often encounter error log units corresponding to multiple array elements of the same structure but different positions. They are completely identical except for the array index (indicating different elements in the array). In order to facilitate the identification of these repeated error log units and avoid multiple outputs, this step introduces a special index mark form for error log units corresponding to array elements with only different array indices, such as "Index 0", "Index 1", etc. For these error log units corresponding to array elements with only different array indices, we remove duplicates and only keep the error log unit corresponding to the first complete array element. The error log units corresponding to the remaining array elements only include the index number and delete the remaining content, thereby achieving the effect of compressing log information and focusing on the essence of the problem.

[0056] Step S32: aligning the length of the field name of the log unit. This refers to uniformizing the display width of all field names to improve readability. The uniformization method is, for example, using the longest field length for easy reading. The following is example four before alignment.

[0057] {"name":"Alice","age":25}

[0058] {"username":"Bob","age":30}

[0059] After alignment, the field names name and age are unified to the longest 8 characters, for example, filled with spaces.

[0060] Step S33: Sort the fields in the log unit by field name. This means arranging the fields in alphabetical order to facilitate quick positioning. For example, the original log unit is {"id": 1, "name": "Alice", "age": 25}, and the three field names are id, name, and age; after sorting by field name, it is {"age": 25, "id": 1, "name": "Alice"}.

[0061] Step S34: Sort the log containers according to the key names of the log containers. This is to facilitate overall browsing. For example, the original log container is as follows.

[0062] {

[0063] "user2":{...},

[0064] "user1":{...}

[0065] }

[0066] The above log container has two log units, and the key names of the log units are user1 and user2.

[0067] After sorting by the key names of the log containers, the resulting log container is as follows.

[0068] {

[0069] "user1":{...},

[0070] "user2":{...}

[0071] }

[0072] The steps S32 to S34 are all used to facilitate user browsing and quick positioning.

[0073] Step S35: According to the content in each log container, generate the description information of each log container. An exemplary description information of a log container is as follows.

[0074] ╆━contact:Contact

[0075] ┆┄phone:Expected to decode'Int'but found‘String’instead.

[0076] ┆┄phone1:Expected to decode'Int'but found‘String’instead.

[0077] It can be found that the description information of the log container has adopted an indented and readable structure, but only the parsing path of the part corresponding to the log container.

[0078] Step S36: All description information of the log container is summarized into a complete JSON parsing error report.

[0079] Still following the previous example three, the JSON parsing error report includes the following content.

[0080]

[0081]

[0082] It can be found that the JSON parsing error report generated by the present application adopts a clear hierarchical structure with layer-by-layer indentation, improving problem analysis efficiency; and provides a complete decoding path user.profile.contact.phone of the phone field where the parsing error occurs, so that the developer can directly locate the JSON field where the parsing error occurs in the complex JSON nested structure, improving maintainability.

[0083] Please refer to Figure 5 The JSON parsing process real-time monitoring system based on the Swift Codable protocol proposed in the present application includes a probe code implanting unit 1, a parsing error recording unit 2, and a parsing report generating unit 3. Figure 5 The system corresponds to Figure 1 The method.

[0084] The probe code implanting unit 1 is used to implant probe code for listening to and recording the decoding process of each JSON field in the JSON decoding container. Whenever a JSON field decoding fails, the probe code records the complete decoding path of the JSON field, the decoding exception type, and the original value.

[0085] The parsing error recording unit 2 is used to record the parsing error information of each JSON field where the parsing error occurs during the JSON data parsing process, and generate a log unit. Multiple log units are classified into a log container.

[0086] The parsing report generating unit 3 is used to generate a structured JSON parsing error report according to the log unit and the log container.

[0087] The JSON parsing process real-time monitoring method proposed in the present application has the following technical innovations and beneficial effects.

[0088] First, the JSON data parsing monitoring process proposed in the present application does not interfere with the decoding business logic of the original Codable protocol, ensuring compatibility and stable performance, and has universality and portability.

[0089] Second, the existing JSON parsing process based on the Swift Codable protocol will terminate the entire JSON data parsing process as soon as any field parsing error of the JSON data occurs. The present application is embedded in the form of a probe code, and when any field parsing error of the JSON data occurs, it does not terminate the JSON data parsing process, but collects information for diagnostic analysis. In this way, the present application outputs batch parsing error information after the JSON data parsing is completed instead of stopping as soon as an error is encountered, which facilitates the repair of multiple problems at a time.

[0090] Third, in the JSON parsing error report generated by the present application, the parsing error of each JSON field includes the complete decoding path, the parsing error type, and the original value of the JSON field. The developer immediately knows which level of the JSON nested structure is wrong, the JSON field that is wrong, and the parsing error type, which shortens the debugging time by more than 70% and significantly improves the development efficiency and reliability.

[0091] Fourth, the present application uses index marking method for array elements with the same error to achieve intelligent deduplication. This method can compress log information and avoid redundant output interference with user reading.

[0092] The above is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application can have various changes and variations. Any modification, equivalent replacement, improvement, etc. within the spirit and principles of the present application shall be included within the scope of protection of the present application.

Claims

1. A real-time monitoring method for JSON parsing process based on Swift Codable protocol, characterized by: The method includes the following steps: Step S1: A probe code is implanted in the JSON decoding container to monitor and record the decoding process of each JSON field. Whenever a JSON field fails to be decoded, the probe code records the complete decoding path, decoding exception type, and original value of the JSON field. Step S2: During the JSON data parsing process, the probe code records the parsing error information of each JSON field where a parsing error occurs, generates a log unit, and classifies the multiple log units into a log container; Step S3: Generate a structured JSON parsing error report according to the log unit and the log container.

2. The method for real-time monitoring of JSON parsing process based on Swift Codable protocol according to claim 1 is characterized in that: The step S1 specifically includes the following sub-steps: Step S11: Rewrite the JSON parser to monitor and record the entire JSON parsing process; Step S12: Encapsulate or proxy the standard JSON decoding container and implant the probe code in it; the probe code monitors and records the decoding process of each JSON field, specifically intercepts the decoding call of each JSON field; whenever a JSON field fails to be decoded, the probe code records the complete decoding path of the JSON field, the type of decoding exception of the JSON field, and the original value of the JSON field.

3. The method for real-time monitoring of JSON parsing process based on Swift Codable protocol according to claim 2 is characterized in that: In step S11, the rewriting technique is subclassing or wrapping class.

4. The method for real-time monitoring of JSON parsing process based on Swift Codable protocol according to claim 2 is characterized in that: In step S12, if the JSON field that fails to be decoded is in the JSON array, the probe code records the array index position of the JSON field; If the JSON field that fails to be decoded is in a JSON object, the probe code records the path of the JSON field in the JSON object.

5. The method for real-time monitoring of JSON parsing process based on Swift Codable protocol according to claim 2 is characterized in that: In step S12, the probe code is used to identify at least three types of decoding exceptions: missing key, empty value, and type mismatch; missing key means that a field is missing in the JSON data, and the corresponding field in the Swift data is a non-optional type, resulting in decoding failure; empty value means that a field in the JSON data exists but the value is empty, and the corresponding field in the Swift data is a non-optional type, resulting in decoding failure; type mismatch means that the type of the field in the JSON data is inconsistent with the type declared by the corresponding field in the Swift data, resulting in a decoding error.

6. The method for real-time monitoring of JSON parsing process based on Swift Codable protocol according to claim 1 is characterized in that: The step S2 specifically includes the following sub-steps: Step S21: When the JSON parser parses the JSON data, the probe code in the JSON decoding container records the complete decoding path, decoding exception type, and original value of the JSON field where decoding failed, which are collectively referred to as the parsing error information of the JSON field; The complete decoding path includes the array index position and object path of the JSON field where decoding failed, and can uniquely locate the JSON field where decoding failed from the root node; Step S22: Generate a log unit for the parsing error information of each JSON field; the log unit is a single record containing the complete decoding path, decoding exception type, and original value of the JSON field; the number of log units is equal to the number of JSON fields that failed to decode; Step S23: Group different log units according to the complete decoding path and nesting level of the corresponding JSON field and classify them into log containers; log units with different levels of the complete decoding path are classified into different log containers; For log units at the same level in some parts of the complete decoding path, the log units at the same level are classified into the same log container, and the log units at different levels are classified into different log containers.

7. The method for real-time monitoring of JSON parsing process based on Swift Codable protocol according to claim 6 is characterized in that: In step S21, the decoding path codingPath of the decoder Decoder in the Swift standard library is monitored in the decoding process, and the codingPath stack structure is dynamically maintained; when encountering a nested JSON object or JSON array, the current field name or array index is automatically pushed into the codingPath stack to construct a complete decoding path from the root node to the current JSON field.

8. The method for real-time monitoring of JSON parsing process based on Swift Codable protocol according to claim 1 is characterized in that: The step S3 specifically includes the following sub-steps: Step S31: remove duplicate log units and empty log containers; Step S32: aligning the length of the field name of the log unit; Step S33: sorting the fields in the log unit according to the field names; Step S34: sorting the log containers according to their key names; Step S35: Generate description information for each log container based on the content in each log container; the description information of the log container adopts an indented structure, but only contains the partial parsing path corresponding to the log container; Step S36: Summarize the description information of all log containers into a complete JSON parsing error report; JSON parsing error reports use an indented hierarchical structure and record the complete decoding path of the JSON field where the parsing error occurred.

9. The method for real-time monitoring of JSON parsing process based on Swift Codable protocol according to claim 8 is characterized in that: In step S31, for error log units corresponding to multiple array elements with the same structure but different positions, except for the different array subscripts, the other contents are the same; an index mark is introduced to deduplicate the error log units corresponding to the array elements "only the array subscripts are different", and only the error log unit corresponding to the complete first array element is retained. The error log units corresponding to the remaining array elements only include the index number and the remaining contents are deleted.

10. A real-time monitoring system for JSON parsing process based on Swift Codable protocol, characterized by: It includes a probe code implantation unit, a parsing error recording unit, and a parsing report generation unit; The probe code implantation unit is used to implant a probe code for monitoring and recording the decoding process of each JSON field in the JSON decoding container; whenever a JSON field fails to be decoded, the probe code records the complete decoding path, decoding exception type, and original value of the JSON field; The parsing error recording unit is used for, during the JSON data parsing process, the probe code to record the parsing error information of each JSON field where a parsing error occurs, and generate a log unit; Group multiple log units into log containers; The parsing report generating unit is used to generate a structured JSON parsing error report according to the log unit and the log container.