CN117742830A - Method and device for realizing unified configuration service system based on JSONPath - Google Patents

Method and device for realizing unified configuration service system based on JSONPath Download PDF

Info

Publication number
CN117742830A
CN117742830A CN202311795301.3A CN202311795301A CN117742830A CN 117742830 A CN117742830 A CN 117742830A CN 202311795301 A CN202311795301 A CN 202311795301A CN 117742830 A CN117742830 A CN 117742830A
Authority
CN
China
Prior art keywords
json
data
data message
jsonpath
path
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311795301.3A
Other languages
Chinese (zh)
Inventor
庄梓源
陈颖豪
刘日星
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China United Network Communications Group Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China United Network Communications Group Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202311795301.3A priority Critical patent/CN117742830A/en
Publication of CN117742830A publication Critical patent/CN117742830A/en
Pending legal-status Critical Current

Links

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The invention discloses a method and a device for realizing unified configuration of a service system based on JSONPath. The method comprises the following steps: firstly, receiving an incoming data message of an upstream system, and storing the incoming data message in a target JSON string in a JSON format to obtain the JSON data message; then, configuring a JSON path according to a data path of the JSON data message; then, using a JSON path analysis library to analyze the JSON data message stored in the target JSON string; secondly, after defining service flow and control flow circulation, carrying out corresponding service logic processing on the JSON data message; and finally, storing the processed JSON data message in a target JSON string and returning the JSON data message to a downstream system to finish the realization of the unified configuration service system based on the JSON path. The method can simplify the data interaction flow, provide a unified and unified data storage read-write method and support the interaction of the upstream and downstream systems, thereby improving the flexibility, performance and development efficiency of the system.

Description

Method and device for realizing unified configuration service system based on JSONPath
Technical Field
The invention relates to the technical field of databases, in particular to a method and a device for realizing uniform configuration of a service system based on JSONPath.
Background
How to realize the unified configuration service system is an industry pain point, and the prior art needs to input research and development resources in four aspects of interface interaction, flow control, data service processing and data information display, and needs to stop the industry and issue. Moreover, even if the business is stopped, only simple structural conversion can be performed, and the functional scene of the current business system cannot be met.
Disclosure of Invention
The invention aims to solve the technical problems of the prior art, and provides a method and a device for realizing unified configuration of a service system based on JSONPath. JSON (JavaScript Object Notation) is a lightweight data exchange format, JSONPath is a query language for locating or selecting content in JSON documents. The method can simplify the data interaction flow, provide a unified and unified data storage read-write method and support the interaction of the upstream and downstream systems, thereby improving the flexibility, performance and development efficiency of the system.
In a first aspect, the present invention provides a method for implementing unified configuration service system based on JSONPath, the method comprising the steps of:
step S1: receiving an incoming data message of an upstream system;
Step S2: storing the incoming data message in a target JSON string in a JSON format to obtain a JSON data message;
the target JSON string is a data structure integrating a plurality of data entities and is a data total set stored in a JSON form;
step S3: configuring a JSON path according to a data path of the JSON data message;
step S4: according to the JSONPath configuration, a JSONPath parsing library is used for parsing the JSON data messages stored in the target JSON string;
step S5: defining a business process and a control process flow according to the analyzed JSON data message;
step S6: according to the flow circulation, carrying out corresponding service logic processing on the JSON data message;
step S7: and storing the processed JSON data message in a target JSON string and returning the JSON data message to a downstream system to finish the realization of the unified configuration service system based on the JSON path.
Further, the step S3 specifically includes the following steps:
step S31: determining a data path of a JSON data message needing to be extracted or operated;
step S32: writing a JSON path expression according to the determined data path of the JSON data message;
step S33: test JSONPath expression:
if the JSONPath expression test fails, repeating the steps S32-S33 until the JSONPath expression test is successful; if the JSONPath expression test is successful, the step S34 is entered;
Step S34: and extracting the JSON data message data through the JSON path expression or extracting the JSON data message data through the JSON path expression and the Groovy script to complete the JSON path configuration.
Further, in the step S34, the extracting JSON data packet data by combining the JSON path expression with the Groovy script specifically includes the following steps:
step S341: positioning needed JSON data message data by using a JSON path expression;
step S342: carrying out data logic processing on JSON data message data through a Groovy script;
step S343: and extracting the general data processing logic so as to multiplex in different scenes, thereby completing the data extraction of the JSON data message.
Further, the step S4 specifically includes the following steps:
step S41: recursively analyzing the target JSON string by using a JSON path analysis library to obtain a data structure of the JSON data message;
step S42: removing invalid JSON data messages based on the data structure of the JSON data messages, and performing post-data processing on target JSON data messages to obtain target JSON data messages;
step S43: based on a path expression of the JSON path, using a set method of the JSON path to assign a value to the target JSON data message to obtain an assigned JSON data message;
Step S44: and carrying out structural conversion on the assigned JSON data message to finish JSON data message analysis.
Further, in the step S5, a service flow and a control flow are defined according to the parsed JSON data message, which specifically includes:
defining a business process according to the parsed JSON data message; and controlling flow circulation according to the analyzed JSON data message;
the service flow is defined according to the parsed JSON data message, and the method specifically comprises the following steps:
step A1: determining key fields of the business process according to the analyzed JSON data message;
step A2: based on key fields of the business process, acquiring a judgment mark by using an eval method of JSONPath; the judging mark is used for determining the current flow needing to be executed;
step A3: analyzing the judgment mark to obtain the needed configuration of the process JSONPath;
step A4: determining a current flow to be executed according to the configuration of the flow JSONPath to finish the definition of the business flow;
the control flow flows according to the parsed JSON data message, and specifically comprises the following steps:
step B1: determining a flow node needing to be circulated according to the current flow needing to be executed;
Step B2: reading JSONPath configuration of flow circulation according to flow nodes needing to be circulated;
step B3: updating the target JSON string according to the read JSON path configuration of the flow stream;
step B4: triggering the circulation of the flow nodes according to the updated target JSON string;
step B5: and constructing a completion message structure of the flow node by using a set method of the JSONPath so as to complete the flow circulation of the current flow node.
Further, the step S6 specifically includes the following steps:
step S61: according to the flow circulation, JSON path configuration is used in the received JSON parameters, and the JSON data message is processed by combining a general processing component and a script of a general JSON parsing library;
step S62: carrying out service logic processing on the JSON data message after service processing;
wherein, the business logic processing comprises:
data storage is carried out on the JSON data message after service processing; and/or the number of the groups of groups,
carrying out data modification on the JSON data message after service processing; and/or the number of the groups of groups,
performing data query on the JSON data message after service processing; and/or the number of the groups of groups,
deleting data of the JSON data message after service processing; and/or the number of the groups of groups,
performing data verification on the JSON data message after service processing;
Step S63: splicing the processed JSON data message to a target JSON string for storage;
step S63: and repeating the steps S61-S63 until all the processes are finished.
Further, the target JSON string in the step S2 is stored in the mongo db, and the storing process thereof includes the steps of:
step S21: converting the target JSON string into a BSON format; the BSON format is a binary JSON format used by MongoDB;
step S22: data in BSON format is inserted into the data set of mongo db so that the target JSON string is stored in mongo db.
Further, after the step S7, the method further includes a step S8,
step S8: displaying the JSON data message;
the step S8 specifically includes the following steps:
step S81: acquiring a JSON data message;
step S82: JSON data message extraction is carried out by using JSON path configuration;
step S83: constructing a data structure for displaying the JSON data message;
step S84: returning the constructed data structure to the front end;
step S85: and carrying out customization processing of data display according to the front-end display requirement so as to realize display of the JSON data message.
In a second aspect, the present invention provides a device for implementing a unified configuration service system based on JSONPath, where the device includes:
The receiving unit is used for receiving the incoming data message of the upstream system;
the storage unit is connected with the receiving unit and is used for storing the incoming data message in a target JSON string in a JSON format to obtain a JSON data message;
the target JSON string is a data structure integrating a plurality of data entities and is a data total set stored in a JSON form;
the configuration unit is connected with the storage unit and is used for configuring the JSON path according to the data path of the JSON data message;
the analysis unit is connected with the configuration unit and is used for analyzing the JSON data message stored in the target JSON string by using a JSON path analysis library according to JSON path configuration;
the first processing unit is connected with the analysis unit and is used for defining a business flow and a control flow circulation according to the analyzed JSON data message;
the second processing unit is connected with the first processing unit and is used for carrying out corresponding service logic processing on the JSON data message according to flow circulation;
and the third processing unit is connected with the second processing unit and is used for storing the processed JSON data message in the target JSON string and returning the JSON data message to a downstream system so as to finish the realization of the unified configuration service system based on the JSON path.
Further, the parsing unit includes:
the analysis module is used for recursively analyzing the target JSON string by using the JSON path analysis library to obtain a data structure of the JSON data message;
the first processing module is connected with the analysis module and is used for judging and eliminating invalid JSON data messages after comparison based on the data structure of the JSON data messages and performing post-data processing on target JSON data messages to obtain target JSON data messages;
the second processing module is connected with the first processing module and is used for assigning values to the target JSON data message by using a set method of the JSON path based on the path expression of the JSON path to obtain an assigned JSON data message;
and the conversion module is connected with the second processing module and is used for carrying out structural conversion on the assigned JSON data message so as to finish JSON data message analysis.
The invention has the beneficial effects that:
1. the invention is based on JSONPath, and can realize flexible positioning and extraction of configuration data, thereby realizing data management in a unified configuration service system.
2. The invention uses JSONPath to configure the service system, which can make the configuration data structure clearer and easier to understand, and improves the readability of the configuration data.
3. The invention realizes the unified configuration service system by using the JSONPath, can unify the format and the management mode of the configuration data, ensures that the configuration data has a consistent structure and management mode in different systems, and improves the uniformity of the configuration data.
The grammar of the JSONPath is similar to XPath, and for developers familiar with XPath or JSON data structure, it is relatively easy to learn and use the JSONPath, can improve developer's development efficiency like this, reduce study cost.
5. The invention can easily locate and extract specific fields and values in the JSON data, so that the configuration system can flexibly locate and extract the data according to the needs, thereby realizing unified configuration of upstream and downstream data.
6. The invention realizes unified configuration through the JSONPath, has clearer structure of configuration data and easy maintenance, and can meet the complex functional scene of the current business system, such as logic judgment, default assignment, configurable method comparison verification, message encryption, SFTP uploading and the like.
7. The invention can process and manage the data meeting different service demands and has stronger expandability.
8. According to the invention, through collecting the total data in the service into one large JSON string and combining with a document storage data source adapting to a high-performance JSON structure mode, the barriers of storing the data of flows, different services and different use scenes in different object structure tables in the traditional service system can be broken; the unified data storage mode simplifies data management and access, and improves the flexibility and performance of the system.
9. The invention utilizes the parsing and construction capability of JSONPath, can replace the traditional DAO layer data value method, and realizes the unified read-write operation of the data stored in the document type data source. The method eliminates the complexity of the traditional storage and reading operation of writing different DAO layer interfaces and database SQL, and improves the uniformity and efficiency of data operation.
10. By using JSON unified storage and combining the parsing and construction capability of JSON path, the invention can process the upstream input data structure, process the stored data and construct the return downstream data structure, thereby supporting the interaction and data transmission of the upstream and downstream systems. The method simplifies the data interaction flow between the systems and improves the flexibility and efficiency of system integration.
11. The invention utilizes the eval resolving capability and the set constructing capability of the JSONPath, combines the general logic call of the Groovy script, and can process complex service scenes, such as logic judgment, default assignment, configurable method comparison verification, message encryption, SFTP uploading and other functional scenes. The method enables the system to support more complex and flexible service requirements, and improves the application range and flexibility of the system.
12. The invention combines the JSONPath with the JSON data content, the constructed interface interactive collocation capability, message construction capability and data processing capability, combines the flow engine and the Groovy script capability as complex logic processing supplement, can build a general collocation low-code service system, supports the functions of upstream and downstream system interaction, flow control, data processing, data display and the like, and improves the collocation flexibility and development efficiency of the system.
Drawings
Fig. 1 is a schematic diagram of a method for implementing a unified configuration service system by JSONPath in an embodiment of the present invention;
fig. 2 is an overall framework diagram of a JSONPath implementation unified configuration service system in an embodiment of the present invention;
FIG. 3 is a schematic diagram of a flow definition JSONPath configuration in an embodiment of the present invention;
FIG. 4 is a schematic diagram of a JSONPath configuration of a process flow in an embodiment of the present invention;
FIG. 5 is a schematic diagram of an interface interaction JSONPath configuration in an embodiment of the present invention;
FIG. 6 is a diagram of a data presentation JSONPath configuration in an embodiment of the present invention;
FIG. 7 is a schematic diagram of a logic handling JSONPath configuration in an embodiment of the present invention;
FIG. 8 is a schematic diagram illustrating JSONPath parsing in an embodiment of the present invention;
FIG. 9 is a schematic diagram of flow control in an embodiment of the invention;
FIG. 10 is a schematic diagram of data storage according to an embodiment of the present invention;
fig. 11 is a schematic diagram of a device for implementing a unified configuration service system by JSONPath in an embodiment of the present invention;
wherein, the reference numerals: 10. receiving unit, 20, storage unit, 30, configuration unit, 40, analysis unit, 50, first processing unit, 60, second processing unit, 70, third processing unit.
Detailed Description
In order to make the technical scheme of the present invention better understood by those skilled in the art, the following detailed description of the embodiments of the present invention will be given with reference to the accompanying drawings.
It is to be understood that the specific embodiments and figures described herein are merely illustrative of the invention, and are not limiting of the invention.
It is to be understood that the various embodiments of the invention and the features of the embodiments may be combined with each other without conflict.
It is to be understood that only the portions relevant to the present invention are shown in the drawings for convenience of description, and the portions irrelevant to the present invention are not shown in the drawings.
It should be understood that each unit and module in the embodiments of the present invention may correspond to only one physical structure, may be formed by a plurality of physical structures, or may be integrated into one physical structure.
It will be appreciated that, without conflict, the functions and steps noted in the flowcharts and block diagrams of the present invention may occur out of the order noted in the figures.
It is to be understood that the flowcharts and block diagrams of the present invention illustrate the architecture, functionality, and operation of possible implementations of systems, apparatuses, devices, methods according to various embodiments of the present invention. Where each block in the flowchart or block diagrams may represent a unit, module, segment, code, or the like, which comprises executable instructions for implementing the specified functions. Moreover, each block or combination of blocks in the block diagrams and flowchart illustrations can be implemented by hardware-based systems that perform the specified functions, or by combinations of hardware and computer instructions.
It should be understood that the units and modules related in the embodiments of the present invention may be implemented by software, or may be implemented by hardware, for example, the units and modules may be located in a processor.
Example 1:
as shown in fig. 1, the present embodiment provides a method for implementing a unified configuration service system based on JSONPath, where the method includes the following steps:
step S1: and receiving an incoming data message of an upstream system.
If the received data message is in a JSON format, the system needs to analyze according to the message format, and a JSON analysis library (such as Jackson, gson and the like) can be used for analyzing data to convert the data in the JSON format into a data structure in the system. If the received signal is not in the JSON format, the signal is converted into the JSON format, and the conversion in the step S1 or the conversion in the step S2 can be carried out.
Step S2: storing the incoming data message in a target JSON string in a JSON format to obtain a JSON data message; the target JSON string is a data structure that merges a plurality of data entities and stores the data aggregate in JSON form.
The target JSON string may also be referred to as a large JSON string.
As a specific implementation manner, the target JSON string in the step S2 is stored in a mongo db, and the storage process includes the following steps:
step S21: converting the target JSON string into a BSON format; the BSON format is a binary JSON format used by MongoDB;
step S22: data in BSON format is inserted into the data set of mongo db so that the target JSON string is stored in mongo db.
The embodiment adopts a document type storage system combining a large JSON string with MongoDB to convert the large JSON string into a document format of MongoDB. MongoDB supports nested structured document storage, so different levels of large JSON strings can be stored in a nested form of documents. With the MongoDB's document storage system, the data structures can be designed and organized more flexibly. Compared with the traditional relational database, the method has the advantages that data does not need to be stored according to a predefined table structure, the data structure can be adjusted and expanded at any time according to actual needs, the limitation of inherent table structure design of the relational database is avoided, and in the traditional relational database, complex JOIN operation can be caused by inquiring through a plurality of tables. In the MongoDB document storage system, related data can be stored in the same document or the nested document is used for representing the association relation, so that the complexity of multi-table query is reduced. When inquiring, only the inquiry language and the instruction provided by MongoDB are used for judging and screening the conditions of the fields in the document. And the performance is greatly improved by the unique identification index and the text index.
Step S3: and configuring the JSON path according to the data path of the JSON data message.
As a specific embodiment, the step S3 specifically includes the following steps:
step S31: determining a data path of a JSON data message needing to be extracted or operated;
step S32: writing a JSON path expression according to the determined data path of the JSON data message;
step S33: test JSONPath expression:
if the JSONPath expression test fails, repeating the steps S32-S33 until the JSONPath expression test is successful; if the JSONPath expression test is successful, the step S34 is entered;
step S34: and extracting the JSON data message data through the JSON path expression or extracting the JSON data message data through the JSON path expression and the Groovy script to complete the JSON path configuration.
As a more specific embodiment, in step S34, the extracting JSON data packet data by combining the JSON path expression with the Groovy script specifically includes the following steps:
step S341: positioning needed JSON data message data by using a JSON path expression;
step S342: carrying out data logic processing on JSON data message data through a Groovy script;
step S343: and extracting the general data processing logic so as to multiplex in different scenes, thereby completing the data extraction of the JSON data message.
Step S4: according to the JSONPath configuration, a JSONPath parsing library is used for parsing JSON data messages stored in a target JSON string.
As a specific embodiment, step S4 specifically includes the following steps:
step S41: recursively analyzing the target JSON string by using a JSON path analysis library to obtain a data structure of the JSON data message;
step S42: based on the data structure of the JSON data message, judging and eliminating invalid JSON data messages after comparison, and performing post-data processing on target JSON data messages to obtain target JSON data messages;
specifically, judging and rejecting invalid JSON data messages, and performing post-processing on target JSON data messages generally need to be performed according to specific service requirements and data structures. The embodiment adopts the following judgment and processing flow:
judging invalid JSON data message:
syntax errors: and analyzing the JSON data message by using a JSON analyzer, and if the analysis fails, indicating that the JSON data message has grammar errors, marking the JSON data message as invalid data and rejecting the JSON data message.
Business logic errors: and checking the data in the JSON data message according to the service rule, and marking the data as invalid data and removing the invalid data if the data does not accord with the service rule.
And (3) comparison: according to the service requirement, the target JSON data message can be compared with other data to determine the validity of the data or perform operations such as data merging. The compared objects can be other data sources, data in a database, or other JSON data messages.
Post data processing:
data cleaning: and performing data cleaning on the target JSON data message, such as removing repeated data, removing invalid data, removing sensitive information and the like.
Data conversion: and according to the service requirement, performing data format conversion or field mapping on the target JSON data message so as to meet the subsequent service processing requirement.
Data merging: and merging the target JSON data message with other data to generate a new data message.
In practical applications, the specific flow of judgment and processing will vary depending on the business requirements and the complexity of the data structure. The flow of judgment and processing is generally designed by combining specific business scenes and data characteristics. In the judging and processing, the JSON analysis library and the data processing library in the programming language can be utilized to efficiently perform data processing operation.
Step S43: based on a path expression of the JSON path, using a set method of the JSON path to assign a value to the target JSON data message to obtain an assigned JSON data message;
Step S44: and carrying out structural conversion on the assigned JSON data message to finish JSON data message analysis.
Step S5: and defining a business flow and a control flow according to the analyzed JSON data message.
As a specific embodiment, in step S5, defining a business process and a control process flow according to the parsed JSON data packet, specifically including:
defining a business process according to the parsed JSON data message; and controlling flow circulation according to the analyzed JSON data message;
the service flow is defined according to the parsed JSON data message, and the method specifically comprises the following steps:
step A1: determining key fields of the business process according to the analyzed JSON data message;
step A2: based on key fields of the business process, acquiring a judgment mark by using an eval method of JSONPath; the judging mark is used for determining the current flow needing to be executed;
step A3: analyzing the judgment mark to obtain a needed positioning process JSONPath configuration;
step A4: determining a current flow to be executed according to the configuration of the flow JSONPath to finish the definition of the business flow;
the control flow flows according to the parsed JSON data message, and specifically comprises the following steps:
Step B1: determining a flow node needing to be circulated according to the current flow needing to be executed;
step B2: reading JSONPath configuration of flow circulation according to flow nodes needing to be circulated;
step B3: updating the target JSON string according to the read JSON path configuration of the flow stream;
step B4: triggering the circulation of the flow nodes according to the updated target JSON string;
step B5: and constructing a completion message structure of the flow node by using a set method of the JSONPath so as to complete the flow circulation of the current flow node.
Step S6: and carrying out corresponding service logic processing on the JSON data message according to the flow circulation.
As a specific embodiment, step S6 specifically includes the following steps:
step S61: according to the flow circulation, JSON path configuration is used in the received JSON parameters, and the JSON data message is processed by combining a general processing component and a script of a general JSON parsing library;
step S62: carrying out service logic processing on the JSON data message after service processing;
wherein, the business logic processing comprises:
data storage is carried out on the JSON data message after service processing; and/or the number of the groups of groups,
carrying out data modification on the JSON data message after service processing; and/or the number of the groups of groups,
Performing data query on the JSON data message after service processing; and/or the number of the groups of groups,
deleting data of the JSON data message after service processing; and/or the number of the groups of groups,
performing data verification on the JSON data message after service processing;
a specific data store is to store the data in a message in a database or other data storage medium for subsequent query and modification operations.
The specific data modification is to modify the existing data according to the data in the message, such as updating user information, modifying order status, etc.
Specific data query refers to querying corresponding data, such as user information, order list, etc., from a database or other data storage medium according to request parameters in the message.
The specific data deletion is to delete the corresponding data in the database or other data storage medium, such as deleting user information, deleting order records, etc., according to the data in the message.
And (3) data verification: and according to the data in the message, checking the data format and the validity, such as checking whether the mobile phone number input by the user meets the format requirement, checking whether the order amount exceeds the limit, and the like.
Step S63: splicing the processed JSON data message to a target JSON string for storage;
Step S63: and repeating the steps S61-S63 until all the processes are finished.
Step S7: and storing the processed JSON data message in a target JSON string and returning the JSON data message to a downstream system.
Step S8: displaying the JSON data message;
the step S8 specifically includes the following steps:
step S81: acquiring a JSON data message;
step S82: JSON data message extraction is carried out by using JSON path configuration;
step S83: constructing a data structure for displaying the JSON data message;
step S84: returning the constructed data structure to the front end;
step S85: and carrying out customization processing of data display according to the front-end display requirement so as to realize display of the JSON data message.
In order to more clearly show the embodiment, as shown in fig. 2, the lightweight service system construction scheme implemented by the embodiment may be divided into: the system comprises a flow control module (a second module), a JSONPath data analysis configuration module (a first module) and a data storage module (a third module), so as to support four main scenes of an Internet system: interaction of upstream and downstream systems, flow control, data processing and data display.
The first module (JSONPath data parsing configuration module) is a core module of the scheme of the embodiment, and the module can be divided into a "configuration module" and a "parsing module".
The JSONPath configuration module is divided into: the method comprises the steps of procedure definition JSONPath configuration, procedure flow JSONPath configuration, interface interaction JSONPath configuration, data display JSONPath configuration, return result JSONPath configuration and logic processing JSONPath configuration, and specifically comprises the following steps:
1. as shown in fig. 3, the "flow definition JSONPath configuration" is used in cooperation with the flow control module to implement the determination of the flow. The decision of the flow is the basis of everything, the flow is formed by a plurality of nodes, the nodes are also units of JSONPath configuration, each node event is matched with other interface interaction JSONPath configuration, data display JSONPath configuration, return result JSONPath configuration and logic processing JSONPath configuration, the four JSONPath configurations are matched in one data entity, the four JSONPath configurations are uniformly acquired and used for subsequent scenes, and the other four configurations realize the functional scenes of the service system. Because the method of the embodiment uses the same universal adaptive interface code to support various scenes and business processes, how to determine which process template is used when the universal interface is currently entered is determined, the configuration is needed to be used, the JSON message segment path configured by the configuration is adopted, the eval method of the JSON path is adopted to obtain the judgment identification in the specific message, the identification is transmitted into the process control module, and the analysis and gateway configuration are adopted to locate the specific process template of the process control module, so that the judgment of the process is realized. If a flow configuration is configured in the database, wherein key fields comprise judgment identifications, gateway configuration, flow identifications, flow operation, next flow identifications and the like, when cloud service order data enter the module, the required flow is positioned through analyzing data to select the judgment identifications, namely product types and service types, so as to select the corresponding flow configuration, then the flow operation in the flow configuration is executed through reflection, and then the result data returned by the flow operation is transmitted to gateway configuration, and the gateway configuration analyzes the result data, so as to judge which step the next flow event should be, and the flow service event such as order receiving, service system notification, order system feedback, service system completion, order system lease and the like is judged, and the like until the service order flow is completed.
In addition to eval methods, other methods may obtain the identifier in a specific message, such as XPath, XML DOM, regular expression, etc. However, in the JSON message, the eval method is simpler, more convenient and more efficient, and can use the JSON path grammar to locate specific fields, so that the method is more flexible and easy to use. The eval method has the advantages that specific fields in the JSON message can be rapidly analyzed, accurate positioning can be achieved according to the JSON path grammar, and the implementation code is simple and high in efficiency. Moreover, the eval method can directly execute the expression in the JS, so that the characteristics of flexibility, dynamics and configurability are realized, and the eval method is applicable to different scenes and business requirements.
2. As shown in fig. 4, the "flow stream JSONPath configuration" is based on the coding of the current flow node of the flow control module according to the completion condition of the interface response, to read the flow stream configuration of the node in the database, construct the completion message structure of the flow node by the set method of JSONPath, update the data of the "large JSON string" entering the service stream, and trigger the stream of the flow node by the flow control module. If the service order data flow enters the order receiving link, after the order receiving process event configuration is read, the specific return code, the return instruction and the specific information in the data are pieced together through a set method of JSON path to form a return message, and the contents of the return message are stored into the large JSON string data.
3. As shown in fig. 5, the "interface interaction JSONPath configuration" is a set of "interface interaction JSONPath configuration" of each different business scenario process, in which different upstream and downstream interaction events have their own set of "interface interaction JSONPath configuration" according to the process node information of the process definition inside the process definition, and the process node information is read from the database. The processing process is that the request JSON message is firstly transmitted from an upstream system, the request structure is pieced into a large JSON string for storage, the large JSON string breaks through the limitation of a data structure, the data structures of a plurality of data entities are fused, a data total set is stored in a JSON form, then the interface-interacted JSON path is configured to analyze and process the data in the large JSON string, eval and set methods are combined, and the configuration rule and the script are combined through an analysis module, so that the request JSON string transmitted to a downstream system is constructed. Therefore, the circulation processing of the business system in the upstream and downstream systems is realized, and the data are maintained in the data storage module through the storage of the large JSON.
4. As shown in fig. 6, the "data display JSON path configuration" refers to that the "large JSON string" in the data storage module is configured and extracted, and a response message structure of the data display is constructed, so that the response message structure is displayed back at the front end of the service system, and the essential conditions in the service system are supported based on the method: and supporting some data visualization scenes such as product information, order information, approval information, flow tracking information and the like.
The 'return result JSONPath configuration' refers to that in the interface interaction process of the service system, different data processing or flow circulation logic needs to be triggered according to the return result of the interface response of the interaction system. Therefore, the configuration of the return result is needed, a series of return information fields with judging function are read according to the field path set by the JSONPath, and then certain comparison is carried out with the target value in the configuration, so as to trigger the following steps: and notifying different subsequent service logics such as downstream system, abnormal single return, short message notification event trigger and the like.
6. As shown in fig. 7, the "logical processing JSONPath configuration" is the portion combined with the "parsing module" and is mainly responsible for processing data in the interface interaction process, so that the data is easily confused with the parameter-out configuration in the interface interaction configuration. The method has the advantages that after JSON parameters are transmitted into an upstream system, the method can be added into a large JSON string for storage, but a scene for carrying out service processing on request data exists in a service scene, and the processing of general data is carried out in a code, but the method realizes the value of the data processing through JSON path, realizes the data processing by combining a general processing component and a script of an analysis module, constructs the processed data through JSON path configuration, and splices the processed data into the large JSON string for storage.
As shown in fig. 8, the JSONPath parsing module is mainly used for processing data in cooperation with the configuration module, and bears support: and five functions of JSON structure recursion analysis, judgment comparison, post-processing, result assignment and structure conversion are realized.
1. After each JSON request data enters a JSON path data analysis configuration module constructed by the scheme of the embodiment, firstly using 'JSON structure recursion analysis', inquiring a highest-layer root node needing to construct a message interface by a first layer, constructing a tree structure of the highest-layer root node, and then analyzing downwards according to a series of read JSON path configurations; the second layer solves the middle layer of the message, the middle layer of the tree interface, recursively processes the middle layer until the leaf layer is resolved; and the third layer of leaf assignment layer needs to consider whether the leaf assignment of the layer is a default value or a source message value, and whether the leaf assignment is a precondition judgment exists before the assignment, because the leaf layer of the JSON structure really needs to be subjected to numerical processing and assignment, and a general method is constructed by using a recursion algorithm to analyze various JSON structures.
2. Before numerical processing is carried out, a certain logic judgment exists in a normal business scene, so that the method supports simple and complex judgment comparison through simple expression analysis and matching with a grosvy script.
3. Some simple numerical processes are wide to be supported through general code logic, but some complex business scenes may need to do complex personalized post-processing operations such as message encryption and SFTP uploading, in this embodiment, a grosvy script is used, business data in an assignment process is transmitted into the grosvy script, the script writes a series of complex and personalized processing operations which cannot be written through general code logic, functions such as message encryption and SFTP uploading are realized, finally, the post-processing can be formed into components, and the post-special scene support of the data is realized by combining configuration and a responsibility chain design mode.
4. After some columns are processed, a set method of JSONPath is used for realizing 'result assignment' by combining path expressions in configuration.
5. Finally, some business scenes may be subject object types when entering into the parameters, but the parameters are required to be array structures, and the api of the JSONPath cannot support the transformation, so that a structure transformation function is built for supporting.
As shown in fig. 9, the second module (flow control module) is mainly divided into two parts, namely flow definition and flow circulation, to provide a flow base api for opening a flow, completing an event and the like, and to support the service scenario call of the service system of the method requiring flow control. The flow definition part has two concepts of flow and flow event, the flow consists of flow event, the flow event represents each system interaction call, and the event directly has two circulation and judgment actions of sequence and gateway. The flow circulation part is responsible for storing information related to flow circulation, so as to support circulation sequence and gateway judgment of the control flow.
The flow definition part is mainly used for the configuration of the flow definition JSONPath, and the service request is sent to judge which flow the flow definition needs to be opened is. The process flow part uses the configuration of the process flow JSONPath, and according to the configuration of the JSONPath, the decision formula and script judgment are combined to find out which event the next process flow should flow to, thereby realizing the process flow.
As shown in fig. 10, the third module (data storage module) plays a role of storing a large JSON string, the common business system uses a relational database to store data of a process, different businesses and different usage scenarios in different object structure tables, and the method uses the large JSON string to break the barriers of the series of data storage; and the JSONPath analysis acquisition capability is combined to replace the common dao layer data value method, and the cache and document type data source storage are combined to improve the performance, so that the data reading method is unified. The method supports unified data storage and unified reading of the business system, the data is divided by the flow, one flow instance of the same business flow (which can be understood as a business flow of a whole scene) is a basic unit, the upstream data, the downstream return, the flow data, the data processing result and the like related to the scene are all stored in one JSON string, and the JSON path configuration carries out positioning reading and assignment updating through a path expression.
The three modules are mutually dependent and act, a set of basic code method for supporting various service scenes is established, and the subsequently accessed service can realize low-code support only by one configuration according to the use rule. The service system built by the method in the embodiment has the advantages of low codes, low investment and the like.
Example 2:
as shown in fig. 11, this embodiment provides a device for implementing a unified configuration service system based on JSONPath, where the device includes:
a receiving unit 10, configured to receive an incoming data packet of an upstream system.
And the storage unit 20 is connected with the receiving unit 10 and is used for storing the incoming data message in the target JSON string in a JSON format to obtain the JSON data message.
The target JSON string is a data set that fuses data structures of a plurality of data entities and is stored in JSON form.
And the configuration unit 30 is connected with the storage unit 20 and is used for configuring the JSONPath according to the data path of the JSON data message.
And the parsing unit 40 is connected with the configuration unit 30, and is used for parsing the JSON data message stored in the target JSON string by using a JSON path parsing library according to JSON path configuration.
As a specific embodiment, the parsing unit 40 includes:
The analysis module is used for recursively analyzing the target JSON string by using the JSON path analysis library to obtain a data structure of the JSON data message;
the first processing module is connected with the analysis module and is used for judging and eliminating invalid JSON data messages after comparison based on the data structure of the JSON data messages and performing post-data processing on the target JSON data messages to obtain target JSON data messages;
the second processing module is connected with the first processing module and is used for assigning values to the target JSON data message by using a set method of the JSON path based on the path expression of the JSON path to obtain an assigned JSON data message;
and the conversion module is connected with the second processing module and is used for carrying out structural conversion on the assigned JSON data message so as to finish JSON data message analysis.
The first processing unit 50 is connected to the parsing unit 40, and is configured to define a business process and a control process flow according to the parsed JSON data message.
The second processing unit 60 is connected to the first processing unit 50, and is configured to perform corresponding service logic processing on the JSON data packet according to the flow.
The third processing unit 70 is connected to the second processing unit 60, and is configured to store the processed JSON data packet in the target JSON string, and return the processed JSON data packet to the downstream system, so as to implement a unified configuration service system based on JSON path.
It is to be understood that the above embodiments are merely illustrative of the application of the principles of the present invention, but not in limitation thereof. Various modifications and improvements may be made by those skilled in the art without departing from the spirit and substance of the invention, and are also considered to be within the scope of the invention.

Claims (10)

1. A method for realizing unified configuration of service systems based on JSONPath is characterized by comprising the following steps:
step S1: receiving an incoming data message of an upstream system;
step S2: storing the incoming data message in a target JSON string in a JSON format to obtain a JSON data message;
the target JSON string is a data structure integrating a plurality of data entities and is a data total set stored in a JSON form;
step S3: configuring a JSON path according to a data path of the JSON data message;
step S4: according to the JSONPath configuration, a JSONPath parsing library is used for parsing the JSON data messages stored in the target JSON string;
step S5: defining a business process and a control process flow according to the analyzed JSON data message;
step S6: according to the flow circulation, carrying out corresponding service logic processing on the JSON data message;
Step S7: and storing the processed JSON data message in a target JSON string and returning the JSON data message to a downstream system to finish the realization of the unified configuration service system based on the JSON path.
2. The method for implementing a unified configuration service system based on JSONPath as recited in claim 1, wherein,
the step S3 specifically comprises the following steps:
step S31: determining a data path of a JSON data message needing to be extracted or operated;
step S32: writing a JSON path expression according to the determined data path of the JSON data message;
step S33: test JSONPath expression:
if the JSONPath expression test fails, repeating the steps S32-S33 until the JSONPath expression test is successful; if the JSONPath expression test is successful, the step S34 is entered;
step S34: and extracting the JSON data message data through the JSON path expression or extracting the JSON data message data through the JSON path expression and the Groovy script to complete the JSON path configuration.
3. The method for implementing a unified configuration service system based on JSONPath as recited in claim 2, wherein,
in step S34, extracting JSON data message data by combining a JSONPath expression with a Groovy script specifically includes the following steps:
Step S341: positioning needed JSON data message data by using a JSON path expression;
step S342: carrying out data logic processing on JSON data message data through a Groovy script;
step S343: and extracting the general data processing logic so as to multiplex in different scenes, thereby completing the data extraction of the JSON data message.
4. The method for implementing a unified configuration service system based on JSONPath as recited in claim 1, wherein,
the step S4 specifically includes the following steps:
step S41: recursively analyzing the target JSON string by using a JSON path analysis library to obtain a data structure of the JSON data message;
step S42: removing invalid JSON data messages based on the data structure of the JSON data messages, and performing post-data processing on target JSON data messages to obtain target JSON data messages;
step S43: based on a path expression of the JSON path, using a set method of the JSON path to assign a value to the target JSON data message to obtain an assigned JSON data message;
step S44: and carrying out structural conversion on the assigned JSON data message to finish JSON data message analysis.
5. The method for implementing a unified configuration service system based on JSONPath as recited in claim 1, wherein,
In the step S5, a service flow and a control flow are defined according to the parsed JSON data message, which specifically includes:
defining a business process according to the parsed JSON data message; and controlling flow circulation according to the analyzed JSON data message;
the service flow is defined according to the parsed JSON data message, and the method specifically comprises the following steps:
step A1: determining key fields of the business process according to the analyzed JSON data message;
step A2: based on key fields of the business process, acquiring a judgment mark by using an eval method of JSONPath; the judging mark is used for determining the current flow needing to be executed;
step A3: analyzing the judgment mark to obtain the needed configuration of the process JSONPath;
step A4: determining a current flow to be executed according to the configuration of the flow JSONPath to finish the definition of the business flow;
the control flow flows according to the parsed JSON data message, and specifically comprises the following steps:
step B1: determining a flow node needing to be circulated according to the current flow needing to be executed;
step B2: reading JSONPath configuration of flow circulation according to flow nodes needing to be circulated;
Step B3: updating the target JSON string according to the read JSON path configuration of the flow stream;
step B4: triggering the circulation of the flow nodes according to the updated target JSON string;
step B5: and constructing a completion message structure of the flow node by using a set method of the JSONPath so as to complete the flow circulation of the current flow node.
6. The method for implementing a unified configuration service system based on JSONPath as recited in claim 1, wherein,
the step S6 specifically comprises the following steps:
step S61: according to the flow circulation, JSON path configuration is used in the received JSON parameters, and the JSON data message is processed by combining a general processing component and a script of a general JSON parsing library;
step S62: carrying out service logic processing on the JSON data message after service processing;
wherein, the business logic processing comprises:
data storage is carried out on the JSON data message after service processing; and/or the number of the groups of groups,
carrying out data modification on the JSON data message after service processing; and/or the number of the groups of groups,
performing data query on the JSON data message after service processing; and/or the number of the groups of groups,
deleting data of the JSON data message after service processing; and/or the number of the groups of groups,
performing data verification on the JSON data message after service processing;
Step S63: splicing the processed JSON data message to a target JSON string for storage;
step S63: and repeating the steps S61-S63 until all the processes are finished.
7. The method for implementing a unified configuration service system based on JSONPath as recited in claim 1, wherein,
the target JSON string in the step S2 is stored in the mongo db, and the storage process thereof includes the steps of:
step S21: converting the target JSON string into a BSON format; the BSON format is a binary JSON format used by MongoDB;
step S22: data in BSON format is inserted into the data set of mongo db so that the target JSON string is stored in mongo db.
8. The method for implementing a unified configuration service system based on JSONPath according to any one of claims 1 to 7,
after the step S7, the method further comprises a step S8,
step S8: displaying the JSON data message;
the step S8 specifically includes the following steps:
step S81: acquiring a JSON data message;
step S82: JSON data message extraction is carried out by using JSON path configuration;
step S83: constructing a data structure for displaying the JSON data message;
step S84: returning the constructed data structure to the front end;
Step S85: and carrying out customization processing of data display according to the front-end display requirement so as to realize display of the JSON data message.
9. A device for implementing a unified configuration service system based on JSONPath, the device comprising:
the receiving unit is used for receiving the incoming data message of the upstream system;
the storage unit is connected with the receiving unit and is used for storing the incoming data message in a target JSON string in a JSON format to obtain a JSON data message;
the target JSON string is a data structure integrating a plurality of data entities and is a data total set stored in a JSON form;
the configuration unit is connected with the storage unit and is used for configuring the JSON path according to the data path of the JSON data message;
the analysis unit is connected with the configuration unit and is used for analyzing the JSON data message stored in the target JSON string by using a JSON path analysis library according to JSON path configuration;
the first processing unit is connected with the analysis unit and is used for defining a business flow and a control flow circulation according to the analyzed JSON data message;
the second processing unit is connected with the first processing unit and is used for carrying out corresponding service logic processing on the JSON data message according to flow circulation;
And the third processing unit is connected with the second processing unit and is used for storing the processed JSON data message in the target JSON string and returning the JSON data message to a downstream system so as to finish the realization of the unified configuration service system based on the JSON path.
10. The apparatus for implementing a unified configuration service system based on JSONPath as recited in claim 9, wherein,
the parsing unit includes:
the analysis module is used for recursively analyzing the target JSON string by using the JSON path analysis library to obtain a data structure of the JSON data message;
the first processing module is connected with the analysis module and is used for judging and eliminating invalid JSON data messages after comparison based on the data structure of the JSON data messages and performing post-data processing on target JSON data messages to obtain target JSON data messages;
the second processing module is connected with the first processing module and is used for assigning values to the target JSON data message by using a set method of the JSON path based on the path expression of the JSON path to obtain an assigned JSON data message;
and the conversion module is connected with the second processing module and is used for carrying out structural conversion on the assigned JSON data message so as to finish JSON data message analysis.
CN202311795301.3A 2023-12-25 2023-12-25 Method and device for realizing unified configuration service system based on JSONPath Pending CN117742830A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311795301.3A CN117742830A (en) 2023-12-25 2023-12-25 Method and device for realizing unified configuration service system based on JSONPath

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311795301.3A CN117742830A (en) 2023-12-25 2023-12-25 Method and device for realizing unified configuration service system based on JSONPath

Publications (1)

Publication Number Publication Date
CN117742830A true CN117742830A (en) 2024-03-22

Family

ID=90259089

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311795301.3A Pending CN117742830A (en) 2023-12-25 2023-12-25 Method and device for realizing unified configuration service system based on JSONPath

Country Status (1)

Country Link
CN (1) CN117742830A (en)

Similar Documents

Publication Publication Date Title
US20170177634A1 (en) Creating data in a data store using a dynamic ontology
KR101755365B1 (en) Managing record format information
CN109491989B (en) Data processing method and device, electronic equipment and storage medium
US9229971B2 (en) Matching data based on numeric difference
CN110502227B (en) Code complement method and device, storage medium and electronic equipment
CN110597844B (en) Unified access method for heterogeneous database data and related equipment
US11487742B2 (en) Consistency checks between database systems
CN111241182A (en) Data processing method and apparatus, storage medium, and electronic apparatus
CN109522341A (en) Realize method, apparatus, the equipment of the stream data processing engine based on SQL
CN111460241B (en) Data query method and device, electronic equipment and storage medium
CN111176656B (en) Complex data matching method and medium
CN112783867A (en) Database optimization method for meeting real-time big data service requirements and cloud server
CN110008448B (en) Method and device for automatically converting SQL code into Java code
CN116911240A (en) Command configuration method, device, equipment and medium of electronic automation design software
CN117742830A (en) Method and device for realizing unified configuration service system based on JSONPath
CN115292313A (en) Pseudo-column implementation method and device, electronic equipment and storage medium
CN115422202A (en) Service model generation method, service data query method, device and equipment
CN115048359A (en) Universal data processing architecture design method for multi-type access data sources
CN115599976B (en) User grouping method, device, electronic equipment and storage medium
CN113157726B (en) Database processing method and device
CN115952203B (en) Data query method, device, system and storage medium
CN117668024A (en) SQL statement analysis-based data processing and synchronizing method and system
US11263192B2 (en) Hyper-folding information in a uniform interaction feed
US20210318858A1 (en) Method, apparatus, and computer readable storage medium for monitoring a data chain
CN117827902A (en) Service data processing method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination