A method for parsing multi-level complex messages in 5G communication scenarios
By re-encapsulating and caching the Linux built-in JSON encoding library, a concise encoding/decoding library interface is provided, solving the problem of efficient parsing of multi-level complex messages in the billing domain of the telecommunications industry, and improving parsing efficiency and development efficiency.
Patent Information
- Application Number
- CN202310004240.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-03
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2043-01-03
AI Technical Summary
Existing JSON parsing methods cannot meet the high-performance requirements of the billing domain in the telecommunications industry, especially in parsing complex multi-level messages, resulting in performance loss and reduced development efficiency.
By re-encapsulating the Linux built-in JSON encoding library, a concise encoding/decoding library interface is provided. Nodes are created and field values are retrieved using the path method, reducing nested loops and lowering time complexity. The parsing process is also optimized through caching.
It achieves efficient multi-level complex message parsing in C/C++ programming language, improves the coding efficiency and code readability of developers, reduces time complexity, and improves parsing efficiency by 30%-50%.
Smart Images

Figure CN116095201B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of communication, and particularly relates to a multi-level complex message analysis method suitable for a communication 5G scene. BACKGROUND
[0002] After the 5G service is put into operation and popularized, the transmission protocol of the bill information of the billing domain of the telecommunication industry is gradually changed from the original file protocol to the message protocol. Before 2018, based on the performance requirement, in the interaction between the back-end service and the network element, the message protocol is mainly the DCC protocol based on C / C++, and a small number of HTTP+Json protocols are mainly used in the architecture of Ajax and the like. After 2018, based on the development of the HTTP technology, the HTTP2 and the like transmission protocols are gradually used for the data interaction between the billing domain network element and the network element and between the application modules, and the data format is gradually converted from the xml to the Json.
[0003] The JSon is a lightweight data exchange format, easy to read and write, and easy to machine parse and generate. These characteristics make JSON an ideal data exchange language.
[0004] The message protocol adopts the RestFull design architecture and the Http+Json format. After the HTTP protocol is upgraded from the 1.0 version to the 2.0 version, the transmission efficiency and the concurrent performance can fully meet the demand of the current back-end application of the billing domain of the telecommunication industry; regarding the data format analysis, the API of the Json analysis in the industry is mainly based on the Java language, such as the Gson of Google. In the use process based on the scene of the back-end application of the telecommunication billing, the C / C++ is still the main programming language, and the Json encoding and decoding library disclosed for the C / C++ is few.
[0005] At present, the daily magnitude of the bill data of the billing domain of the telecommunication industry is in the order of hundreds of millions, and the connection mode is real-time online connection. According to the standard requirement in the telecommunication industry, the processing efficiency of each bill end to end is within 1s, and the processing links of the bill involved include seven links of the network element, the agent, the preprocessing, the kick, the pricing, the account and the reminder in turn, as shown in the following table. Figure 2 The performance requirement of each link cannot be higher than 200ms. Based on this performance requirement, in the case that the HTTP2 protocol is used for the bill message, the data format adopts the Json format, and the bill format for the billing service is as follows:
[0006]
[0007]
[0008] From the format of the bill, the hierarchical structure of the bill is much more complex than the Json message of the common front-end business, mainly manifested in that: (1) the level of the message is generally more than 5 levels; (2) the message body is large, most of the messages will exceed 1M in the transmission process of some links, and some even reach nearly 10M; (3) due to the natural complexity of the business, there are many field definitions in the message, which basically include user, customer, number, subscription, sales instance, sales, attribute, state, stop machine track, bill type, cost, traffic, voice and the like.
[0009] At present, the existing message analysis method generally adopts an open source Json library. The basic analysis method is as follows:
[0010] Method one:
[0011]
[0012] Method two:
[0013]
[0014] For method one, too many business levels and too large message cause performance loss in the whole bill analysis process, and the time complexity is O (n^2).
[0015] For method two, the time complexity is reduced, but the complexity is increased in the business development process, and the developer uses an array for the multi-level business element, and the identification in [] needs to be compared one by one with the data dictionary. The code readability is reduced, and the development efficiency is reduced.
[0016] Most of the other disclosed Json analysis is based on Java language, which cannot meet the performance requirements of the telecommunication billing domain. And the message data body needs to be loaded multiple times in the bill analysis process, as shown in Figure 3 , each time the Json analysis is performed, the whole process of loading the message, basic analysis, loop search according to the key, outputting the value and destroying needs to be repeated, and for Figure 2 , the performance loss is caused by multiple loop searches. SUMMARY
[0017] In view of the above problems, the application provides a multi-level complex message analysis method suitable for a communication 5G scene, provides a simple, Json data format and C / C++ programming language based general encoding and decoding library, simplifies the use mode of the existing Json encoding and decoding library, reduces the number of loop nesting, and reduces the time complexity of the program.
[0018] To achieve the above object, the application discloses a multi-level complex message analysis method suitable for communication 5G scene, comprising:
[0019] The Json encoding library of Linux is encapsulated again to obtain independent encoding function calling interfaces, including creating a new Json_object node and creating a new Json_object group node, and independent decoding function calling interfaces, including loading a Json message to be parsed and obtaining a field value;
[0020] The developer selects each encoding function calling interface or decoding function calling interface according to needs and adds them to the corresponding application function;
[0021] When the message is parsed, the decoding function calling interface of loading a Json message to be parsed is called to load and cache the Json message data;
[0022] The encoding function calling interface of creating a new Json_object node or the encoding function calling interface of creating a new Json_object group node is called to create a Json_object node or a Json_object group node based on the path;
[0023] The decoding function calling interface of obtaining a field value is called to repeatedly read the cached Json message data based on the created Json_object node or Json_object group node to obtain each field value.
[0024] As a further improvement of the application,
[0025] The encoding function calling interface further includes setting the values of multiple nodes;
[0026] After each field value is obtained, the encoding function calling interface of setting the values of multiple nodes is called to output each field name and each field value according to a preset structure based on the path to obtain a data analysis result.
[0027] As a further improvement of the application,
[0028] The data analysis result is returned in the path mode.
[0029] As a further improvement of the application,
[0030] The decoding function calling interface further includes cache release;
[0031] After the data analysis result code is obtained, the decoding function calling interface of cache release is called to release the cached Json message data.
[0032] As a further improvement of the present application,
[0033] When the Json message data is cached, a map form is adopted; the path is stored in the key of the map.
[0034] As a further improvement of the present application,
[0035] When the Json message data cached is repeatedly read based on the created Json_object node or the Json_object group node, the field value is obtained, and the method comprises the following steps:
[0036] The path of each field in the created Json_object node or the Json_object group node is taken as the key to perform data positioning in the Json message data cached in the map form, and the Value corresponding to each field is found.
[0037] As a further improvement of the present application,
[0038] The decoding function calling interface further comprises obtaining the maximum repetition number of the field.
[0039] As a further improvement of the present application,
[0040] When the Json encoding library of Linux is secondarily encapsulated, the C or C++ programming language is adopted.
[0041] As a further improvement of the present application,
[0042] The encoding function calling interface and the decoding function calling interface can be called through the calling mode of the dynamic library or the static library.
[0043] The code files of the encoding function calling interface and the decoding function calling interface can also be directly integrated into the corresponding application function.
[0044] Compared with the prior art, the present application has the beneficial effects that:
[0045] Firstly, the number of methods in the encoding and decoding library is simplified through secondary encapsulation, the most use scenarios of the encoding and decoding of the telecommunication service data are guaranteed, and the number of methods in the encoding and decoding library is reduced from more than 20 to less than 10; secondly, the number of service levels is simplified through the path mode, and the time complexity of analysis is reduced; then, the message data can be cached for multiple times and repeatedly used, and the performance loss caused by repeatedly loading the message data is avoided by controlling the storage mode of the message cache and the time of releasing and storing; finally, the message analysis method of the present application greatly improves the readability of the code written by the developer and the development efficiency.
[0046] The application adopts a Json coding library provided by Linux as a basic Json library, and can adapt to multi-platform usage modes.
[0047] The Json coding and decoding library after secondary packaging provided by the application can be used multiple times when complex message analysis is performed, and is released after all business processing of the message is completed, thereby reducing performance loss caused by multiple initializations.
[0048] The application provides a simple, Json data format-oriented and C / C++ programming language-based general coding and decoding library, reduces the number of APIs in the existing Json coding and decoding library, simplifies the usage mode of the existing Json coding and decoding library, reduces the number of loop nesting times, reduces the time complexity of the program, and enables developers to clearly see the association between the first level and the last level during development, thereby reducing the time complexity of multi-level complex message analysis from O(n^2) to O(n).
[0049] The method of the application enables developers to directly perform path-based coding according to the code, and the efficiency of the coding and decoding process is improved by 30%-50%, without the need to frequently search a dictionary document for upper and lower level relationships, and the code is clear and readable. BRIEF DESCRIPTION OF DRAWINGS
[0050] Figure 1 A multi-level complex message analysis method flowchart suitable for a communication 5G scenario is disclosed for an embodiment of the application.
[0051] Figure 2 A message processing link schematic diagram of a telecommunication industry billing domain is disclosed as the background technology of the application.
[0052] Figure 3 A message data multiple loading flowchart of an existing multi-level complex message analysis process is disclosed as the background technology of the application.
[0053] Figure 4 A complex flowchart of an existing multi-level complex message analysis is disclosed for an embodiment of the application.
[0054] Figure 5 A simple flowchart of a multi-level complex message analysis suitable for a communication 5G scenario is disclosed for an embodiment of the application. DETAILED DESCRIPTION
[0055] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0056] The present application will be further described in detail below with reference to the drawings:
[0057] As shown in the accompanying drawings, Figure 1 The present application discloses a multi-level complex message analysis method suitable for a communication 5G scenario, which comprises:
[0058] S1, the Linux self-contained Json encoding library is encapsulated again to obtain independent encoding function calling interfaces, including: creating a new Json_object node, creating a new Json_object group node, setting the value of multiple group nodes, and obtaining the maximum repetition number of fields, to obtain independent decoding function calling interfaces, including: loading the Json message to be parsed, buffer release, and obtaining the field value;
[0059] Among them,
[0060] In order to adapt to the use mode of multiple platforms, the basic json library uses the Linux self-contained Json encoding library, and the original multiple APIs are encapsulated into seven on the basis of the Json encoding library, as shown in Table 1:
[0061] Table 1
[0062]
[0063]
[0064] Further,
[0065] The encoding and decoding functions are independent respectively, and the user can freely select and use according to the actual situation;
[0066] When the Linux self-contained Json encoding library is encapsulated again, C or C++ programming language is used.
[0067] Further,
[0068] The encoding function calling interface and the decoding function calling interface can be called through the calling mode of dynamic library or static library;
[0069] The code files of the encoding function calling interface and the decoding function calling interface can also be directly integrated into the corresponding application function.
[0070] S2, the developer selects each encoding function call interface or decoding function call interface according to needs to add to the corresponding application function;
[0071] S3, when the message is parsed, the decoding function call interface of loading the Json message to be parsed is called, and the Json message data is loaded and cached;
[0072] Among them,
[0073] When caching the Json message data, the map form is used; the path is stored in the key of the map.
[0074] S4, the encoding function call interface of creating a new Json_object node or creating a new Json_object group node is called, and the Json_object node or Json_object group node is created based on the path;
[0075] Among them,
[0076] Create the Json_object node, and the code example is as follows:
[0077] CreateJsonObjectByPath(“ / PRODOFFERINFO
[0078] / OFFERNBR / OFFEREXPDATE”);
[0079] Further,
[0080] “ / PRODOFFERINFO / OFFERNBR / OFFEREXPDATE” is the path recorded by the path.
[0081] Further,
[0082] The path of each field in the created Json_object node or Json_object group node is used as the key to locate the data in the cached Json message data in the form of map, and the corresponding Value of each field is found.
[0083] S5, the decoding function call interface of obtaining the field value is called, and the cached Json message data is repeatedly read based on the created Json_object node or Json_object group node, so as to obtain the field value.
[0084] S6, after obtaining the field value, the encoding function call interface of setting the value of multiple groups of nodes is called, and each field name and each field value is output according to the preset structure based on the path form, so as to obtain the data parsing result.
[0085] wherein,
[0086] The data analysis result is returned in the form of path.
[0087] S7, after obtaining the data analysis result code, a cache release decoding function calling interface is called to release the cached Json message data.
[0088] Embodiment 1:
[0089] As Figure 4 shown, based on the existing message analysis mode in the background art, the complexity of the mode of the multi-level Json configuration file for the developer is high, as follows:
[0090]
[0091] The present application simplifies the Json configuration file, and the simplified file configuration mode is as follows:
[0092] Name / base / offer / attr / * / * / *
[0093] As Figure 5 shown, in this file configuration mode, when the developer needs to implement the application function of "obtaining the value of each field", the decoding function calling interface "obtaining the field value" in the Json encoding and decoding library is called, and the code is run:
[0094] GetFieldValueByName(“ / name / base / offer / attr / * / * / *”)
[0095] That is, the path mode can be directly used to locate the key and the corresponding value to be searched in the message, which greatly shortens the message analysis time and reduces the time complexity.
[0096] The Json encoding and decoding library of the present application uses the mode of " / key1 / key2[n] / key3 / key4 / * / *" to replace the original loop search mode, and this direct positioning mode reduces the time complexity caused by the loop search.
[0097] Embodiment 2:
[0098] For Figure 2 the bill processing link of the telecommunication industry billing domain, the HTTP2+Json protocol mode is used for data interaction in the proxy, preprocessing and kicking interaction process; the analysis of the Json message in each interaction process uses the encoding and decoding mode of the present application to process the message, including:
[0099] The following mode is used to load the message data in the code processing process:
[0100] Step 1, jsonDecode->LoadJsonBuff("message data")
[0101] Load and use multiple times;
[0102] Step 2, create a new Json_Object node:
[0103] jsonEncode->CreateJsonObjectByPath(" / PRODOFFERINFO
[0104] / OFFERNBR / OFFEREXPDATE");
[0105] Step 3, repeatedly read the message data multiple times to obtain the data parsing result;
[0106] jsonDecode->GetFieldValueByName(string("* / * / * / RESULTCODE"));
[0107] After using this method, the time complexity is reduced from O(n^2) to O(n).
[0108] Advantages of the application:
[0109] The application first simplifies the number of methods in the encoding and decoding library through secondary packaging, ensures that most of the use scenarios of telecommunication service data encoding and decoding are covered, and reduces the number of methods in the encoding and decoding library from more than 20 to less than 10; secondly, the application simplifies the number of service levels through the path mode, reduces the time complexity of analysis; then, the application also controls the storage mode and release time of message cache, so that the message data can be cached once and used repeatedly, avoiding the performance loss caused by repeatedly loading message data; finally, the message parsing method of the application greatly improves the readability of the code written by the developer and the development efficiency.
[0110] The application adopts the Json encoding library provided by Linux as the basic Json library, which can adapt to the use mode of multiple platforms.
[0111] The secondary packaged Json encoding and decoding library provided by the application only needs to initialize the json message data once when performing complex message parsing, and the json message data can be used multiple times after being loaded into the cache, and then released after all the business processing of the message in this session is completed. Thus, the performance loss caused by multiple initializations is reduced.
[0112] The application provides a concise, Json data format-oriented, C / C++ programming language-based general encoding and decoding library, reduces the number of APIs in the existing Json encoding and decoding library, simplifies the use mode of the existing Json encoding and decoding library, reduces the number of loop nesting, reduces the time complexity of the program, and enables the developer to clearly see the association between the first level and the last level in the development process, reduces the time complexity of multi-level complex message analysis from O(n^2) to O(n).
[0113] The method of the application enables the developer to directly write the code according to the path mode, the implementation efficiency of the encoding and decoding process is improved by 30%-50%, and the upper and lower level relationships do not need to be frequently searched in the dictionary document.
[0114] The above is only the preferred embodiment of the application and is not used to limit the application, and the application can have various changes and variations for those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the application shall be included in the protection scope of the application.
Claims
1. A method for parsing multi-level complex messages in a communication 5G scenario, characterized in that, The application relates to a method for parsing a multi-layer complex message under a 5G communication scenario. The method comprises the following steps: a secondary encapsulation is performed on a Json coding library of Linux to obtain independent coding function calling interfaces, including creating a new Json_object node, creating a new Json_object group node and setting values of multiple group nodes, and independent decoding function calling interfaces are obtained, including loading a Json message to be parsed and obtaining field values; a developer selects the coding function calling interfaces or the decoding function calling interfaces according to needs and adds the interfaces to corresponding application functions; when a message is parsed, the loading Json message to be parsed decoding function calling interface is called to load and cache Json message data; the creating new Json_object node or the creating new Json_object group node coding function calling interface is called to create a Json_object node or a Json_object group node based on a path; the obtaining field values decoding function calling interface is called to repeatedly read the cached Json message data based on the created Json_object node or the Json_object group node, and field values are obtained; the setting values of multiple group nodes coding function calling interface is called to output field names and field values in a preset structure based on a path, and a data parsing result is obtained.
2. The method for parsing a multi-layer complex message under a 5G communication scenario according to claim 1, wherein: 3.The method for parsing multi-level complex messages suitable for communication in a 5G scenario according to claim 1, characterized in that: the data parsing result is returned in a path mode. the decoding function calling interface further comprises a cache release; 4.The method for parsing multi-level complex messages suitable for communication in a 5G scenario according to claim 1, characterized in that: after the data parsing result code is obtained, the cache release decoding function calling interface is called to release the cached Json message data.
5. The method of claim 4, wherein the method is applied to the parsing of multi-level complex messages in a 5G communication scenario. when the Json message data is cached, a map form is adopted; and the path is stored in the key of the map. when the created Json_object node or the Json_object group node is repeatedly read to obtain field values, the following steps are included: 6.The method for parsing multi-level complex messages suitable for communication in a 5G scenario according to claim 1, characterized in that: the path of each field in the created Json_object node or the Json_object group node is taken as a key to perform data positioning in the cached Json message data in a map form, and the corresponding Value of each field is found.
7. The method of claim 1, wherein the method is applied to a multi-level complex message in a 5G communication scenario. the decoding function calling interface further comprises an obtaining field maximum repetition number function. 8.The method for parsing multi-level complex messages suitable for communication in a 5G scenario according to claim 1, characterized in that: when the secondary encapsulation is performed on the Json coding library of Linux, a C or C++ programming language is adopted. the coding function calling interfaces and the decoding function calling interfaces can be called through a dynamic library or a static library; the code files of the coding function calling interfaces and the decoding function calling interfaces can be directly integrated into corresponding application functions.
Citation Information
Patent Citations
Storing and processing JSON documents in a SQL database table
US20190102389A1