Json-based interaction and verification method, system and device

By introducing a common JSON data transmission and validation mechanism into the interface definition, the problem of joint communication between front-end and back-end developers was solved, which simplified the development process and reduced costs.

CN114090294BActive Publication Date: 2026-01-02HAOYUN TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111394641.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-23
Publication Date
2026-01-02
Estimated Expiration
2041-11-23

AI Technical Summary

Technical Problem

The existing interface definitions require front-end and back-end developers to jointly define and develop interfaces, resulting in a heavy workload and increased communication costs.

Method used

By pre-defining general JSON transmission data through business modeling, it receives and parses JSON data from Hypertext Transfer Protocol requests, verifies the legality of input parameter descriptions, executes business logic or returns exceptions, simplifying the front-end and back-end development process.

Benefits of technology

It reduces communication and management costs for front-end and back-end developers, simplifies the development process, and reduces development time and resource investment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114090294B_ABST
    Figure CN114090294B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of computers, in particular to a json-based interaction and verification method, system and device, which comprises the following steps: defining general json transmission data in advance through business modeling; receiving a hypertext transfer protocol request and reading corresponding general json transmission data; analyzing the general json transmission data to obtain request parameters; analyzing the request parameters to obtain input parameter description; verifying whether the input parameter description is legal; if yes, executing business logic and returning obtained request result data; and if no, directly returning an exception; the method solves the problem that existing interface definition needs to be defined and developed by front-end developers and back-end developers, which not only leads to heavy development workload, but also increases the communication cost of developers; the method provided by the application can make developers coordinate and connect through defined general json transmission data, shortens the development cycle and improves the development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to an interaction and verification method, system and device based on json. BACKGROUND

[0002] At present, with the increasing business functions that front-end and back-end developers need to handle, the interfaces for connection are gradually increasing. However, the traditional interface definition usually requires the front-end and back-end developers to coordinate and develop the connection, which not only leads to heavy development workload, but also increases the communication cost of the developers, thereby leading to long development cycle, low efficiency and waste of manpower. SUMMARY

[0003] The present application provides an interaction and verification method, system and device based on json, which solves the technical problem that the existing interface definition requires the front-end and back-end developers to define and develop the connection, which not only leads to heavy development workload, but also increases the communication cost of the developers.

[0004] To solve the above technical problems, the present application provides an interaction and verification method, system and device based on json.

[0005] In a first aspect, the present application provides an interaction and verification method based on json, which comprises the following steps:

[0006] Defining the json general transmission data in advance through business modeling;

[0007] Receiving a hypertext transfer protocol request and reading the corresponding json general transmission data according to the hypertext transfer protocol request;

[0008] Analyzing the json general transmission data to obtain the request parameters;

[0009] Analyzing the request parameters to obtain the input parameter description;

[0010] Verifying whether the input parameter description is legal, if yes, executing the business logic and returning the request result data obtained, if not, directly returning the exception.

[0011] In a further embodiment, the request parameters include the input parameter description and the output parameter description.

[0012] In a further embodiment, the step of verifying whether the input parameter description is legal comprises:

[0013] Verifying the maximum length of the input field and the object type in the input parameter description, if the verification is passed, it means legal, if the verification is not passed, it means illegal.

[0014] In a further implementation form, the request result data comprises the input parameter description and the output parameter description.

[0015] In a further implementation form, the method further comprises: acquiring the corresponding json universal transmission data according to the request result data, and filling the acquired json universal transmission data to the corresponding data configuration control.

[0016] In a further implementation form, the data format of the request result data is consistent with the data format of the json universal transmission data.

[0017] In a second aspect, the present application provides a json-based interaction and verification system, which comprises:

[0018] A data definition module is configured to define the json universal transmission data in advance through business modeling.

[0019] A data receiving module is configured to receive a hypertext transfer protocol request and read the corresponding json universal transmission data according to the hypertext transfer protocol request.

[0020] A data processing module is configured to parse the json universal transmission data to obtain request parameters and parse the request parameters to obtain an input parameter description.

[0021] A data verification module is configured to verify whether the input parameter description is legal, and if so, execute business logic and return the obtained request result data, and if not, directly return an exception.

[0022] In a further implementation form, the data verification module specifically comprises:

[0023] The input field maximum length and object type in the input parameter description are verified, and if the verification is passed, it is indicated that the input parameter description is legal, and if the verification is not passed, it is indicated that the input parameter description is not legal.

[0024] In a third aspect, the present application further provides a computer device comprising a processor and a memory, wherein the processor is connected with the memory, the memory is configured to store a computer program, and the processor is configured to execute the computer program stored in the memory, so that the computer device executes the steps of the above method.

[0025] The application provides a json-based interaction and verification method, system and device, and through the method, the technical solution of freely adding json data definition attribute description to meet different request data is realized. Compared with the prior art, the method provides a unified interface docking method independent of front-end and back-end development progress through unified json general transmission data, and developers do not need to define each interface separately; by using the technical solution provided by the application, the verification work can be reduced, and the development of multiple and miscellaneous interfaces can be reduced, thereby simplifying the development process. BRIEF DESCRIPTION OF DRAWINGS

[0026] Figure 1 is a json-based interaction and verification method flowchart provided by an embodiment of the application;

[0027] Figure 2 is a json-based interaction and verification system schematic diagram provided by an embodiment of the application;

[0028] Figure 3 is a structural schematic diagram of a computer device provided by an embodiment of the application. DETAILED DESCRIPTION

[0029] The embodiments of the application are specifically described below with reference to the drawings, and the embodiments are given only for illustrative purposes, and cannot be understood as limiting the application, including the drawings are used only for reference and illustration, and do not constitute a limitation on the protection scope of the patent of the application, because many changes can be made to the application without departing from the spirit and scope of the application.

[0030] In view of the problem that the existing interface definition needs to be defined and developed by front-end developers and back-end developers together, which not only leads to heavy development workload, but also increases the communication cost of developers, an embodiment of the application provides a json-based interaction and verification method, as shown in Figure 1 The method comprises the following steps:

[0031] S1. Predefining json general transmission data through business modeling.

[0032] In this embodiment, a user sends a data generation request to a data modeling unit, the data modeling unit obtains a role information table according to the data generation request, and sends the role information table to a business modeling unit, the business modeling unit generates json general transmission data according to the role information table and other data definitions, and sends the json general transmission data to a page modeling unit, the page modeling unit binds the generated json general transmission data and corresponding data configuration controls, and the following is an example of the defined json general transmission data format:

[0033]

[0034]

[0035] S2. receiving a hypertext transfer protocol request and reading corresponding json universal transmission data according to the hypertext transfer protocol request.

[0036] S3. parsing the json universal transmission data to obtain request parameters.

[0037] In an embodiment, the request parameters include input parameter description and output parameter description. The input parameter and the output parameter in the request parameters can reduce the communication cost of front-end and back-end developers, and different descriptions can realize different business functions, such as adding decimal place attribute, limiting the maximum length of decimal place, etc.

[0038] S4. parsing the request parameters to obtain input parameter description.

[0039] S5. checking whether the input parameter description is legal, if yes, executing business logic and returning request result data obtained, and if not, directly returning an exception.

[0040] The request result data includes the input parameter description and the output parameter description, and the data format of the request result data is consistent with the data format of the json universal transmission data.

[0041] In an embodiment, the step of checking whether the input parameter description is legal includes:

[0042] checking the maximum length of the input field and the object type in the input parameter description, if the checking is passed, it means that the input parameter description is legal, and if the checking is not passed, it means that the input parameter description is not legal.

[0043] The embodiment adds an errorMsg attribute, so that when the input parameter description is checked, if there is a case that the checking is not passed, the attribute value uniformly throws an exception information to the front-end developer.

[0044] In an embodiment, the method further includes: obtaining corresponding json universal transmission data according to the request result data, and filling the obtained json universal transmission data to a corresponding data configuration control.

[0045] In the embodiment, after receiving an HTTP (Hyper Text Transfer Protocol) request, the server reads corresponding JSON general transmission data, and parses and verifies the JSON general transmission data. After verification, the server normally executes business logic, and returns corresponding request result data to the business modeling unit according to a specified transmission protocol. The business modeling unit receives the request result data according to the format of the JSON general transmission data, and fills the returned request result data into corresponding data configuration controls according to the corresponding JSON transmission protocol, to complete the HTTP request. The embodiment better coordinates the communication and communication between the front end and the back end through the defined JSON general transmission data. The front-end and back-end developers are only responsible for the defined JSON general transmission data.

[0046] The embodiment provides a JSON-based interaction and verification method. JSON general transmission data is defined through business modeling. A page binds corresponding data configuration controls according to the defined JSON general transmission data. After receiving an HTTP request, a server reads corresponding JSON general transmission data, and verifies and parses the read JSON general transmission data. The embodiment reduces the time cost and management cost of communication between front-end and back-end developers through unified transmission formats and management verification rules, simplifies the development process, greatly reduces the development time, and enables developers to not need to separately edit each interface definition, but only need to focus on logic processing after data return.

[0047] It should be noted that the size of the serial number of each process does not mean the execution order, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiment of the application.

[0048] In one embodiment, as shown in Figure 2 The embodiment provides a JSON-based interaction and verification system, which comprises:

[0049] The data definition module 101 is configured to define JSON general transmission data through business modeling.

[0050] The data receiving module 102 is configured to receive an HTTP request, and read corresponding JSON general transmission data according to the HTTP request.

[0051] The data processing module 103 is configured to parse the JSON general transmission data to obtain request parameters, and parse the request parameters to obtain input parameter descriptions.

[0052] The data verification module 104 is configured to verify whether the input parameter descriptions are legal. If yes, the data verification module 104 executes business logic, and returns obtained request result data. If not, the data verification module 104 directly returns an exception.

[0053] In one embodiment, the data checking module specifically comprises:

[0054] The input field maximum length and object type in the input parameter description are checked, and if the checking is passed, it is legal, and if the checking is not passed, it is illegal;

[0055] If it is legal, the business logic is executed, and the obtained request result data is returned, and if it is illegal, an exception is directly returned.

[0056] The specific limitations of the json-based interaction and checking system can be seen from the above limitations of the json-based interaction and checking method, and will not be repeated here. Those skilled in the art can realize that the various modules and steps described in combination with the embodiments disclosed in the present application can be realized in hardware, software or both. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0057] Compared with the prior art, the present application uniformly defines the json general transmission data through the data definition module, selects the json general transmission data corresponding to the http request through the data receiving module, verifies and analyzes the json general transmission data through the data processing module and the data checking module, and returns the corresponding data to the page; the system provided in the embodiment can reduce many unnecessary errors by defining the transmission format unified by front-end and back-end developers for communication, and can clearly understand the input parameter, output parameter data and the type of the data of the interface through the data format defined in the embodiment, thereby reducing the management cost.

[0058] Figure 3 The computer device provided in the embodiment of the present application comprises a memory, a processor and a transceiver which are connected through a bus; the memory is used for storing a group of computer program instructions and data, and can transmit the stored data to the processor; the processor can execute the program instructions stored in the memory to execute the steps of the above method.

[0059] The memory can comprise a volatile memory or a non-volatile memory, or can comprise both volatile and non-volatile memories; the processor can be a central processing unit, a microprocessor, a specific application integrated circuit, a programmable logic device or a combination thereof. By way of illustrative but not limiting, the above programmable logic device can be a complex programmable logic device, a field programmable logic gate array, a general array logic or any combination thereof.

[0060] In addition, the memory can be a physically independent unit, or can be integrated with the processor.

[0061] Those skilled in the art can understand that, Figure 3 The person skilled in the art can understand that,

[0062] The embodiment of the present application provides a kind of based on the interaction and verification method, system and equipment of json, and its a kind of based on the interaction and verification method of json is realized by increasing json attribute, the configuration and verification of different functions, with strong expansibility, and guarantee the legitimacy of data;While the embodiment is reduced by the unified standardization processing of interface, the time cost and development cost of front-end and back-end developer communication, reduce the development resource input.

[0063] The above-described embodiments only express several preferred embodiments of the present application, which are described in detail and specifically, but should not be understood as limiting the scope of the patent. It should be pointed out that for ordinary skilled in the art, without departing from the technical principles of the present application, several improvements and substitutions can be made, which should also be regarded as the protection scope of the present application. Therefore, the protection scope of the present application patent should be subject to the protection scope of the claims.

Claims

1. A method for json-based interaction and validation, characterized in that, The method comprises the following steps: According to the user sent data generation request to get the role information table, and according to the role information table, through business modeling, the json general transmission data is defined in advance; The json general transmission data is sent to the page modeling unit, so that the page modeling unit binds the generated json general transmission data with the corresponding data configuration control; Receive hypertext transfer protocol request, and read the corresponding json general transmission data according to the hypertext transfer protocol request; Parse the json general transmission data to get the request parameter; The request parameter includes input parameter description and output parameter description; The request parameter is parsed to get the input parameter description; Check if the input parameter description is legal, the check includes checking the input field maximum length and object type in the input parameter description, if the check is passed, it means legal; If the check is not passed, it means illegal; If it is legal, execute the business logic, and return the request result data to the business modeling according to the specified transmission protocol, the data format of the request result data is consistent with the data format of the json general transmission data; If not, return an exception directly; According to the json general transmission data, the request result data is received, and the request result data returned is filled into the corresponding data configuration control according to the corresponding json general transmission protocol; The request result data includes the input parameter description and the output parameter description.

2. The method of claim 1, wherein, Also includes: According to the request result data, the corresponding json general transmission data is obtained, and the obtained json general transmission data is filled into the corresponding data configuration control.

3. A json-based interaction and validation system, characterized in that, The system comprises: Data definition module, for obtaining role information table according to user sent data generation request, and defining json general transmission data in advance according to the role information table through business modeling; And, the json general transmission data is sent to the page modeling unit, so that the page modeling unit binds the generated json general transmission data with the corresponding data configuration control; Data receiving module, for receiving hypertext transfer protocol request, and reading the corresponding json general transmission data according to the hypertext transfer protocol request; Data processing module, for parsing the json general transmission data to get the request parameter, and parsing the request parameter to get the input parameter description; The request parameter includes input parameter description and output parameter description; Data checking module, for checking if the input parameter description is legal, the check includes checking the input field maximum length and object type in the input parameter description, if the check is passed, it means legal; If the check is not passed, it means illegal; If it is legal, execute the business logic, and return the request result data to the business modeling according to the specified transmission protocol, the data format of the request result data is consistent with the data format of the json general transmission data; If not, return an exception directly; According to the json general transmission data receiving request result data, and the request result data returned is filled into the corresponding data configuration control according to the corresponding json general transmission protocol; the request result data includes the input parameter description and the output parameter description.

4. A computer device, comprising: The computer device comprises a processor and a memory, the processor is connected with the memory, the memory is used for storing a computer program, and the processor is used for executing the computer program stored in the memory, so that the computer device executes the method in any one of claims 1 to 2.

Citation Information

Patent Citations

  • Form rendering method, device and equipment, and storage medium

    CN111178012A

  • Interface testing method and device

    CN111752846A

  • Method for generating chart by server based on node-canvas

    CN112328317A