Data analysis method and client
By receiving data from the server and performing standardized transformation and JSONPath extended parsing based on online configuration files, the challenges of flexibility and maintenance in client-side data parsing methods are solved, enabling efficient and flexible data processing and display, and improving user experience.
Patent Information
- Application Number
- CN202411285143.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2026-03-13
AI Technical Summary
In existing client-server architectures, JSON parsing methods suffer from high code adaptation costs, poor flexibility, maintenance difficulties, and poor user experience, making it difficult to flexibly adapt to changes in business data structures.
A data parsing method is adopted, which receives business data sent by the server, performs standardized transformation and parsing according to the online configuration file, expands the parsing rules using JSONPath technology, generates formatted strings for display, and combines a structure converter and business attribute parsing to adapt to different data structures.
It improves the system's flexibility and scalability, reduces code development and release costs, enhances application compatibility and stability, and improves data processing efficiency and user experience.
Smart Images

Figure CN121659896A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a data parsing method and client. Background Technology
[0002] Currently, in client-server architectures, client applications typically need to parse and process data from the server based on business requirements. This data is usually transmitted in JSON format. To reference and display business data, JSON parsing techniques are generally used, where the server predefines the parsing structure, and the client parses according to this predefined structure. However, due to the complexity and frequent changes in business logic, this parsing method has shortcomings, such as high code adaptation costs, poor flexibility, difficult maintenance, and poor user experience. JSONPath is a JSON query technique used to locate and extract data within a JSON data structure. It does not require fully parsing the entire data structure; a single expression can retrieve specific data. Therefore, this paper proposes a data parsing method and client based on extensions and optimizations of JSONPath. Summary of the Invention
[0003] The technical problem to be solved by this invention is to provide a data parsing method and client that can flexibly adapt to changes in business data structure to cope with a series of changes in business requirements, thereby reducing code development and release costs and improving application compatibility and stability.
[0004] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0005] A data parsing method, comprising the following steps:
[0006] S1. Receive business data sent by the server, and request the corresponding online configuration file according to the business data;
[0007] S2. Standardize and transform the business data according to the online configuration file, and parse the transformed business data according to the corresponding parsing rules in the online configuration file;
[0008] S3. Generate a format string based on the data attributes corresponding to the display requirements of the business data, and reference and display the corresponding parsed business data according to the data attributes in the format string.
[0009] To solve the above-mentioned technical problems, another technical solution adopted by the present invention is as follows:
[0010] A data parsing client includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the various steps of the data parsing method described above.
[0011] The beneficial effects of this invention are as follows: The data parsing method and client provided by this invention receive business data sent by the server and request the corresponding online configuration file according to the business data, thereby improving the system's flexibility and scalability and flexibly adapting to changes in business data structure; standardizing and converting the business data according to the online configuration file, and parsing the converted business data according to the corresponding parsing rules in the online configuration file, ensuring consistency in business data format, thus improving data processing efficiency and accuracy; generating formatted strings according to the data attributes corresponding to the display requirements of the business data to meet different business needs, thereby reducing code development and release costs, improving application compatibility and stability; and referencing and displaying the corresponding parsed business data according to the data attributes in the formatted strings, realizing data visualization and improving user experience. Attached Figure Description
[0012] Figure 1 This is a flowchart of a data parsing method according to an embodiment of the present invention;
[0013] Figure 2 This is a schematic diagram of a data parsing client according to an embodiment of the present invention;
[0014] Label Explanation:
[0015] 1. A data parsing client; 2. Memory; 3. Processor. Detailed Implementation
[0016] To explain in detail the technical content, objectives, and effects of the present invention, the following description is provided in conjunction with the embodiments and accompanying drawings.
[0017] Please refer to Figure 1 This invention provides a data parsing method, including the following steps:
[0018] S1. Receive business data sent by the server, and request the corresponding online configuration file according to the business data;
[0019] S2. Standardize and transform the business data according to the online configuration file, and parse the transformed business data according to the corresponding parsing rules in the online configuration file;
[0020] S3. Generate a format string based on the data attributes corresponding to the display requirements of the business data, and reference and display the corresponding parsed business data according to the data attributes in the format string.
[0021] As can be seen from the above description, the beneficial effects of the present invention are as follows: By receiving business data sent by the server and requesting the corresponding online configuration file according to the business data, the system's flexibility and scalability are improved, and changes in business data structure are flexibly adapted; the business data is standardized and converted according to the online configuration file, and the converted business data is parsed according to the corresponding parsing rules in the online configuration file, ensuring the consistency of business data format, thereby improving data processing efficiency and accuracy; a formatted string is generated according to the data attributes corresponding to the display requirements of the business data to meet different business needs, thereby reducing code development and release costs, improving application compatibility and stability, and referencing and displaying the corresponding parsed business data according to the data attributes in the formatted string, realizing data visualization and improving user experience.
[0022] Furthermore, the step of requesting the corresponding online configuration file based on the business data includes:
[0023] The system automatically requests the online configuration file at preset intervals and caches the online configuration file from the configuration server to the local machine.
[0024] As described above, by setting a preset period, the configuration file is automatically requested and stored on the configuration server, which allows for flexible modification and improves the system's flexibility and maintainability. Cache the configuration file locally and update it promptly to ensure that the cached configuration file is always up-to-date. This also helps to cope with configuration server downtime and enhances robustness.
[0025] Furthermore, the data attributes of the business data include standard attributes;
[0026] Step S2 specifically includes:
[0027] Determine whether the online configuration file is configured with a structure converter. If so, convert the data attributes of the business data into standard attributes.
[0028] The method of using fixed attribute names is used to parse business data whose data attributes have been converted into standard attributes.
[0029] As described above, by configuring the structure converter, the data attributes of the business data are converted into standard attributes, thereby improving the universality and utilization efficiency of the business data; by using fixed attribute names to parse the business data whose data attributes have been converted into standard attributes, the data processing method is unified, the data processing flow is simplified, and the data processing efficiency is improved, so that users can directly reference the data.
[0030] Furthermore, the data attributes of the business data include business attributes;
[0031] Step S2 further includes:
[0032] Determine whether the business data is configured with business attributes. If so, parse the business attributes of the business data according to the parsing rules described in the online configuration file.
[0033] As described above, by setting different attributes for business data and using corresponding parsing methods for each attribute—namely, using JSON technology to parse standard attribute business data and using JSONPath to dynamically parse business attribute business data—these methods work together to meet business needs, improve flexibility and maintainability. When the data attribute of the business data is a business attribute, the business attribute of the business data is parsed according to the corresponding parsing rules in the online configuration file, ensuring data processing consistency, enhancing data readability, and facilitating the reference and display of business data.
[0034] Furthermore, the step of generating a formatted string based on the data attributes corresponding to the display requirements of the business data includes:
[0035] A corresponding reference format is generated based on the category of the data attribute. When the data attribute is a standard attribute, the reference format is the first reference format. When the data attribute is a business attribute, the reference format is the second reference format.
[0036] As described above, by generating corresponding reference formats based on the categories of data attributes, the accuracy of referencing business data is ensured, errors caused by format mismatch are avoided, and the operability of the data is improved, enabling multiple references to the parsed data to meet display requirements.
[0037] Please refer to Figure 2 Another embodiment of the present invention provides a data parsing client, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the various steps of the data parsing method described above.
[0038] The data parsing method and client described above are applicable to parsing server-side data to meet business display requirements. The following detailed implementation methods illustrate these methods:
[0039] Example 1
[0040] Please refer to Figure 1 A data parsing method, comprising the following steps:
[0041] S1. Receive business data sent by the server and request the corresponding online configuration file based on the business data.
[0042] In this embodiment, business data sent by the server is received, an online configuration file is set, and dynamic parsing is performed through online configuration, which improves the system's flexibility and scalability, flexibly adapts to changes in business data structure, reduces code development and release costs, and enhances application compatibility and stability.
[0043] Furthermore, in this embodiment, the step of requesting the corresponding online configuration file according to the business data includes: automatically requesting the online configuration file at preset intervals and caching the online configuration file from the configuration server to the local machine. For example, the client will automatically request the latest configuration file every 24 hours and cache it locally to ensure that the locally cached configuration file is always up-to-date in order to cope with the configuration server downtime and enhance robustness.
[0044] In this embodiment, parsing rules corresponding to data attributes are defined in the configuration file to facilitate the parsing and processing of business data. For example, the data of a textbook returned by the server is as follows:
[0045]
[0046] }
[0047] The data above shows that the subject of this textbook is "Chinese Language and Literature," the grade is "First Grade," and there are two levels: "Ministry-level Excellent" and "Provincial-level Excellent." The order_num value of "Ministry-level Excellent" is higher than that of "Provincial-level Excellent," indicating that the Ministry-level Excellent is a higher grade. The subject "Chinese Language and Literature" can be parsed using the JSONPath expression "$.subject," and similarly, data such as "First Grade," "Ministry-level Excellent," and "Provincial-level Excellent" can also be parsed. Furthermore, by modifying the JSONPath expression in the online configuration file, changes in display requirements can be accommodated without modifying the client-side code. However, if the business requirement is to display "Chinese Language and Literature - First Grade" or the highest level "Ministry-level Excellent," the traditional JSONPath cannot meet the display requirements because it cannot perform concatenation and size comparison. Therefore, in this embodiment, a custom parsing rule is defined on top of JSONPath to extend its concatenation and comparison capabilities, thus meeting various business display needs. The custom parsing rule template is as follows:
[0048] {
[0049] "mode": "all", / / Parsing mode, values include all, firstNotNull
[0050] "expression_list": [ / / Multiple JSONPath expressions]
[0051] "The first JSONPath expression",
[0052] "Second JSONPath expression", ......
[0054] "The Nth JSONPath expression"
[0055] ],
[0056] "separator": "·" / / separator
[0057] }
[0058] Specifically, when the mode is set to "all", the results of parsing each JSONPath expression are concatenated using a separator. When the mode is set to "firstNotNull", only the data that is not empty after parsing the first JSONPath expression is retrieved. The mode can also be extended as needed. For example, when it is necessary to calculate the sum of the order_num levels, the mode can be defined as "sum" to sum all order_num levels. When it is necessary to obtain the average value of the order_num levels in the business data, the mode can be defined as "average" to obtain the average value.
[0059] In this embodiment, the above-mentioned parsing rule template is used to parse the textbook data of a certain textbook, thereby obtaining the parsed data of "Chinese Language - Grade 1", "Ministry-level Excellent", and "Provincial-level Excellent", specifically as follows:
[0060] Analysis rules for "Chinese Language Arts - Grade 1":
[0061] {
[0062] "mode": "all"
[0063] "expression_list": [
[0064] "$.subject",
[0065] "$.grader"
[0066] ],
[0067] "separator": "·"
[0068] }
[0069] Analysis rules for "Ministerial Excellence":
[0070] {
[0071] "mode": "firstNotNull",
[0072] "expression_list": [
[0073] "$.tag_list[?@.tag_dimension_id=='bkykdj'&&@.order_num===
[0074] '20')].tag_name",
[0075] "$.tag_list[?@.tag_dimension_id=='bkykdj'&&@.order_num===
[0076] '10')].tag_name",
[0077] ],
[0078] "separator": null
[0079] }
[0080] The rules for analyzing "Provincial Excellence" awards are as follows:
[0081] {
[0082] "mode": "firstNotNull",
[0083] "expression_list": [
[0084] "$.tag_list[?@.tag_dimension_id=='bkykdj'&&@.order_num===
[0085] '10')].tag_name",
[0086] "$.tag_list[?@.tag_dimension_id=='bkykdj'&&@.order_num===
[0087] '20')].tag_name",
[0088] ],
[0089] "separator": null
[0090] }
[0091] Furthermore, in the textbook business, when the business definition is changed, it is required to expand the value of the business attribute of textbook grade to three grades: "Ministry Excellent", "Provincial Excellent", and "City Excellent" and display them. Only the parsing of the "City Excellent" grade needs to be added to the configuration file. Its parsing rule is the same as the parsing rule type of "Ministry Excellent" and "Provincial Excellent", and there is no need to modify the client code.
[0092] S2. Standardize and transform the business data according to the online configuration file, and parse the transformed business data according to the corresponding parsing rules in the online configuration file.
[0093] In this embodiment, the data attributes of the business data include standard attributes and business attributes. Standard attributes are basic and static, while business attributes are extended and dynamic. By defining standard attributes and business attributes, different data sources can be flexibly adapted. For example, in the textbook business, the textbook name, subject, and grade are the most basic attributes and are defined as standard attributes, while the highest level (max_level) is a business requirement and is defined as a business attribute. In the introduction of a person business, name, age, gender, and place of origin are basic attributes and are defined as standard attributes, while self-introduction is a business requirement and is defined as a business attribute. By defining a set of standard attributes for fixed parsing in the client program, flexibility is improved while maintenance difficulty is reduced. Based on different data attribute categories, corresponding parsing methods are adopted. Specifically, JSON technology is used to parse standard attribute business data, while JSONPath is used to dynamically parse business attribute business data. These methods work together to meet business needs and improve flexibility and maintainability. Step S2 specifically involves: determining whether the online configuration file has a structure converter; if so, converting the data attributes of the business data to standard attributes using the structure converter. This structure converter adapts to different data structures, improving the universality and utilization efficiency of business data. A fixed attribute name approach is used to parse the business data whose data attributes have been converted to standard attributes, unifying the data processing method, simplifying the data processing flow, eliminating the need for JSONPath expressions for parsing, reducing online configuration workload, and improving data processing efficiency, allowing users to directly reference the data. In the textbook business, when different textbook data structures exist, such as:
[0094] {
[0095] "name": "Textbook Name",
[0096] "tag_list": [
[0097] {
[0098] "tag_dimension_id": "xk",
[0099] "tag_name": "Chinese Language"
[0100] },
[0101] {
[0102] "tag_dimension_id": "xk",
[0103] "tag_name": "Chinese Language"
[0104] } ]
[0106] }
[0107] A structure converter can be used to convert the data attributes of textbook data into standard attributes, automatically completing the data conversion operation without modifying the client code. The `name` attribute is the same for all data types and does not require conversion. The specific content of the structure converter is as follows:
[0108] {
[0109] / / Parse the data using custom rules and convert it into grade standard attributes.
[0110] "grade": {
[0111] "mode": "all"
[0112] "expression_list": [
[0113] "$.tag_list[?@.tag_dimension_id=='dj')].tag_name"
[0114] ],
[0115] "separator": null
[0116] },
[0117] / / Parse the data using custom rules and convert it into standard subject attributes.
[0118] "subject": {
[0119] "mode": "all"
[0120] "expression_list": [
[0121] "$.tag_list[?@.tag_dimension_id=='xk')].tag_name"
[0122] ],
[0123] "separator": null
[0124] }
[0125] }
[0126] Further, in this embodiment, step S2 further includes: determining whether the service data is configured with service attributes. If so, parsing the service attributes of the service data according to the parsing rules described in the online configuration file to ensure the consistency of data processing, enhance data readability, and facilitate the reference and display of service data. Among them, in the business of teaching textbooks, the service attribute max_level is parsed to obtain "Ministry-level Excellence". The specific parsing rule of the service attribute max_level is:
[0127] {
[0128] "max_level": {
[0129] "mode": "firstNotNull",
[0130] "expression_list":
[0131] "$.tag_list[?@.tag_dimension_id == 'bkykdj' && @.order_num ==
[0132] '20')].tag_name",
[0133] "$.tag_list[?@.tag_dimension_id == 'bkykdj' && @.order_num ==
[0134] '10')].tag_name",
[0135] ,
[0136] "separator": null
[0137] }
[0138] }
[0139] S3. Generate a formatted string according to the data attributes corresponding to the display requirements of the service data, and reference and display the parsed service data corresponding to the data attributes in the formatted string.
[0140] In this embodiment, a formatted string is generated according to the data attributes corresponding to the display requirements of the service data to meet different service requirements, and the parsed service data corresponding to the data attributes in the formatted string is referenced and displayed to achieve the visual display of data and improve the user experience.
[0141] Further, in this embodiment, generating a formatted string according to the data attributes corresponding to the display requirements of the service data includes:
[0142] The system generates corresponding reference formats based on the category of data attributes. When the data attribute is a standard attribute, the reference format is a first reference format: {attribute name}. When the data attribute is a business attribute, the reference format is a second reference format: ${attribute name}. By generating corresponding reference formats based on the category of data attributes, the accuracy of referencing business data is ensured, errors caused by format mismatches are avoided, and the operability of the data is improved, allowing for multiple references of parsed data to meet display requirements. For example, in the textbook business, the client page needs to display "
Ministry-level Excellent
${max_level}
[0143] Example 2
[0144] Please refer to Figure 2 A data parsing client 1 includes a memory 2, a processor 3, and a computer program stored on the memory 2 and executable on the processor 3. When the processor 3 executes the computer program, it implements the various steps of a data parsing method according to Embodiment 1.
[0145] In summary, the data parsing method and client provided by this invention receive business data sent by a server, request the corresponding online configuration file based on the business data, and perform dynamic parsing through online configuration. This reduces code development and deployment costs, improves application compatibility and stability, and automatically requests the online configuration file at a preset period. The online configuration file is cached locally from the configuration server to ensure that the locally cached configuration file is always up-to-date, thus addressing configuration service downtime and enhancing robustness. The data attributes of the business data include standard attributes and business attributes. By setting different data attribute categories, business needs can be flexibly addressed while ensuring data maintainability. The method determines whether the online configuration file is configured with a structure converter. If so, the data attributes of the business data are converted to standard attributes according to the structure converter. The business data with converted data attributes is parsed using fixed attribute names. By defining standard attributes, business attributes, and a structure converter, different data structures are adapted, simplifying the data processing flow, reducing online configuration workload, and improving data processing efficiency. It determines whether the business data is configured with business attributes; if so, it parses the business attributes of the business data according to the parsing rules described in the online configuration file. Through custom parsing rules, improvements are made to JSONPath to extend parsing capabilities, flexibly responding to a series of changes in business requirements, ensuring data processing consistency, and enhancing data readability for easy reference and display of business data. A formatted string is generated based on the data attributes corresponding to the display requirements of the business data. Different data attributes correspond to different reference formats, ensuring the accuracy of referencing business data and avoiding errors due to format mismatches. The corresponding parsed business data is referenced and displayed based on the data attributes in the formatted string. The parsed business data can be referenced multiple times to meet display requirements.
[0146] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A data parsing method, characterized in that, Including the following steps: S1. Receive business data sent by the server, and request the corresponding online configuration file according to the business data; S2. Standardize and transform the business data according to the online configuration file, and parse the transformed business data according to the corresponding parsing rules in the online configuration file; S3. Generate a format string based on the data attributes corresponding to the display requirements of the business data, and reference and display the corresponding parsed business data according to the data attributes in the format string.
2. The data parsing method according to claim 1, characterized in that, The step of requesting the corresponding online configuration file based on the business data includes: The system automatically requests the online configuration file at preset intervals and caches the online configuration file from the configuration server to the local machine.
3. The data parsing method according to claim 1, characterized in that, The data attributes of the business data include standard attributes; Step S2 specifically includes: Determine whether the online configuration file is configured with a structure converter. If so, convert the corresponding data attributes of the business data into standard attributes according to the structure converter. The method of using fixed attribute names is used to parse business data whose data attributes have been converted into standard attributes.
4. The data parsing method according to claim 3, characterized in that, The data attributes of the business data include business attributes; Step S2 further includes: Determine whether the business data is configured with business attributes. If so, parse the business attributes of the business data according to the parsing rules described in the online configuration file.
5. The data parsing method according to claim 4, characterized in that, The step of generating a formatted string based on the data attributes corresponding to the display requirements of the business data includes: A corresponding reference format is generated based on the category of the data attribute. When the data attribute is a standard attribute, the reference format is the first reference format. When the data attribute is a business attribute, the reference format is the second reference format.
6. A data parsing client, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it performs the following steps: S1. Receive business data sent by the server, and request the corresponding online configuration file according to the business data; S2. Standardize and transform the business data according to the online configuration file, and parse the transformed business data according to the corresponding parsing rules in the online configuration file; S3. Generate a format string based on the data attributes corresponding to the display requirements of the business data, and reference and display the corresponding parsed business data according to the data attributes in the format string.
7. A data parsing client according to claim 6, characterized in that, The step of requesting the corresponding online configuration file based on the business data includes: The system automatically requests the online configuration file at preset intervals and caches the online configuration file from the configuration server to the local machine.
8. A data parsing client according to claim 6, characterized in that, The data attributes of the business data include standard attributes; Specifically, S2 is: Determine whether the online configuration file is configured with a structure converter. If so, convert the corresponding data attributes of the business data into standard attributes according to the structure converter. The method of using fixed attribute names is used to parse business data whose data attributes have been converted into standard attributes.
9. A data parsing client according to claim 8, characterized in that, The data attributes of the business data include business attributes; Step S2 further includes: Determine whether the business data is configured with business attributes. If so, parse the business attributes of the business data according to the parsing rules described in the online configuration file.
10. A data parsing client according to claim 9, characterized in that, The step of generating a formatted string based on the data attributes corresponding to the display requirements of the business data includes: A corresponding reference format is generated based on the category of the data attribute. When the data attribute is a standard attribute, the reference format is the first reference format. When the data attribute is a business attribute, the reference format is the second reference format.