CN111309593A - JSON interface verification method, device and equipment and computer readable storage medium - Google Patents

JSON interface verification method, device and equipment and computer readable storage medium Download PDF

Info

Publication number
CN111309593A
CN111309593A CN202010051261.1A CN202010051261A CN111309593A CN 111309593 A CN111309593 A CN 111309593A CN 202010051261 A CN202010051261 A CN 202010051261A CN 111309593 A CN111309593 A CN 111309593A
Authority
CN
China
Prior art keywords
json interface
interface data
data
json
target file
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
CN202010051261.1A
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.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China 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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202010051261.1A priority Critical patent/CN111309593A/en
Publication of CN111309593A publication Critical patent/CN111309593A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to the field of research and development management, and particularly discloses a JSON interface checking method, a device, equipment and a computer readable storage medium, wherein a first JSON interface data sent by a server is received, and a corresponding target file is generated based on the first JSON interface data; debugging a preset target application program based on the target file, and receiving second JSON interface data sent by the server; and determining error data of the second JSON interface data according to the target file and the second JSON interface data, realizing the generation of the target file based on the configuration rule of the terminal and the first JSON interface data, directly taking the target file as a comparison basis, omitting a complicated server configuration process, and simplifying a verification process.

Description

JSON interface verification method, device and equipment and computer readable storage medium
Technical Field
The invention relates to the field of research and development management, in particular to a JSON interface verification method, a JSON interface verification device, JSON interface verification equipment and a computer readable storage medium.
Background
In SPA (single page web application) application development, interface development based on a restore (architectural State Transfer) mode is becoming the mainstream of application development. At present, a large number of server interfaces in application transmit data through a JSON format, wherein a JSON (Java Object notification, Java Script Object identifier) is a lightweight data exchange format, and is a main data transmission format for current internet application data transmission due to the characteristics of small data size, fast network transmission, convenient conversion and the like.
Data adjustment of a terminal and a server can be involved in actual application development, the terminal needs to verify interface availability according to an interface document given by the server, and a large amount of time is wasted in manually verifying the interface, so that a mock service is created at present, an interface simulation server is built, simulation data are provided for the terminal when the server does not complete interface development by configuring a series of parameters, interface verification is carried out after the server completes development by configuring verification rules, and the development correctness is verified. However, this method requires building a mock server and using a lot of time to maintain the configuration of the mock server, and the verification rule is accurate to the matching mode of each field, which is too complex.
Disclosure of Invention
The invention mainly aims to provide a JSON interface verification method, a JSON interface verification device, JSON interface verification equipment and a computer-readable storage medium name, and aims to solve the technical problems that mock server needs to be built for the existing interface verification, a large amount of time is used for maintaining mock server configuration, a verification rule is accurate to a matching mode of each field, and a verification process is too complex.
In a first aspect, the present application provides a JSON interface verification method, where the JSON interface verification method includes:
receiving first JSON interface data sent by a server, and generating a corresponding target file based on the first JSON interface data;
debugging a preset target application program based on the target file, and receiving second JSON interface data sent by the server;
and determining error data of the second JSON interface data according to the target file and the second JSON interface data.
In a second aspect, the present application further provides a JSON interface calibration apparatus, where the JSON interface calibration apparatus includes:
the receiving and generating module is used for receiving first JSON interface data sent by a server and generating a target file based on the first JSON interface data;
the debugging and receiving module is used for debugging a preset target application program based on the target file and receiving second JSON interface data sent by the server;
and the determining module is used for determining the error data of the second JSON interface data according to the target file and the second JSON interface data.
In a third aspect, the present application further provides a computer device, including: the JSON interface verification method comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein when the computer program is executed by the processor, the steps of the JSON interface verification method are realized.
In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the method for JSON interface verification described in the above invention.
According to the method, the device, the equipment and the computer readable storage medium for checking the JSON interface, the first JSON interface data sent by the server are received, and the corresponding target file is generated based on the first JSON interface data; debugging a preset target application program based on the target file, and receiving second JSON interface data sent by the server; and determining error data of the second JSON interface data according to the target file and the second JSON interface data, realizing the generation of the target file based on the configuration rule of the terminal and the first JSON interface data, directly taking the target file as a comparison basis, omitting a complicated server configuration process, and simplifying a verification process.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a JSON interface verification method according to an embodiment of the present disclosure;
FIG. 2 is a flow diagram illustrating sub-steps of a JSON interface verification method in FIG. 1;
FIG. 3 is a flow diagram illustrating sub-steps of a JSON interface verification method in FIG. 1;
FIG. 4 is a flow diagram illustrating sub-steps of a JSON interface verification method in FIG. 1;
fig. 5 is a schematic flowchart of another JSON interface verification method according to an embodiment of the present disclosure;
fig. 6 is a schematic block diagram of a JSON interface verification apparatus provided in an embodiment of the present application;
fig. 7 is a schematic block diagram of another JSON interface verification apparatus provided in an embodiment of the present application;
fig. 8 is a block diagram schematically illustrating a structure of a computer device according to an embodiment of the present application.
The implementation, functional features and advantages of the objectives of the present application will be further explained with reference to the accompanying drawings.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The flow diagrams depicted in the figures are merely illustrative and do not necessarily include all of the elements and operations/steps, nor do they necessarily have to be performed in the order depicted. For example, some operations/steps may be divided, combined or partially combined, so that the actual execution sequence may be changed according to actual situations.
The embodiment of the application provides a JSON interface checking method, a JSON interface checking device, JSON interface checking equipment and a computer readable storage medium. The JSON interface verification method can be applied to terminal equipment, and the terminal equipment can be a mobile phone, a tablet computer, a notebook computer, a desktop computer and the like.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
Referring to fig. 1, fig. 1 is a schematic flowchart of a JSON interface verification method according to an embodiment of the present disclosure.
As shown in fig. 1, the JSON interface verification method includes steps S100 to S300.
S100, receiving first JSON interface data sent by a server, and generating a corresponding target file based on the first JSON interface data;
the terminal sends a corresponding request to the server based on the user instruction, and acquires first JSON interface data corresponding to the request in the server. Illustratively, the terminal receives a user operation instruction or a user voice instruction, generates an http request corresponding to the user operation instruction or the user voice instruction, and sends the http request to the server. Http (HyperText transfer Protocol hypertext transfer Protocol) is a most widely applied network Protocol on the Internet, and http requests include six request modes of GET, HEAD, PUT, DELETE, POST and OPTIONS. And when receiving the http request sent by the terminal, the server immediately responds to and calls the interface document corresponding to the http request based on a preset protocol. And the server takes the interface document as first JSON interface data and sends the first JSON interface data to the terminal. The terminal receives first JSON interface configuration data sent by the server, generates a corresponding mock file based on the received first JSON interface data, and takes the mock file as a target file. Illustratively, the definition of the interface document includes the interface name: test interface, method name: get, address: /test, ref: foo, type string, go out: result, type number.
In an embodiment, specifically referring to fig. 2, step S100 includes: substeps S101 to substep S102.
Step S101, sending a preset GET request to a server, and receiving first JSON interface data returned by the server in response to the GET request;
the terminal sends a preset GET request to the server, wherein the GET request is used for acquiring data, and although the GET request can transmit the data, the purpose of transmitting the data is to acquire corresponding data in the server. The server responds to the GET request, calls JDBC (Java DataBase connectivityJava DataBase connection) to take out the interface document corresponding to the GET request from the DataBase, obtains first JSON interface data from the interface document and returns the first JSON interface data to the terminal, wherein the number of JSON interfaces of the server is at least one, the JDBC is a Java API for executing SQL sentences, can provide uniform access for a plurality of relational databases and consists of a group of classes and interfaces written by Java languages.
And a substep S102, if the format of the first JSON interface data is a preset format, generating a corresponding target file based on the first JSON interface data and a preset configuration file.
After receiving first JSON interface data returned by the server responding to the GET request, the terminal detects whether the format of the first JSON interface data is a preset format; if the format of the first JSON interface data is determined not to be the preset format, calling a preset format converter; and modifying the format of the first JSON interface data into a preset format based on a preset format converter. After the terminal acquires the format of the first JSON interface data, whether the format of the first JSON interface data is a preset format is judged. Illustratively, the terminal sets a JSON format or a js format as a preset format of the first JSON interface data in advance, and when the format of the first JSON interface data acquired by the terminal is not the JSON format or the js format, it is determined that the format of the first JSON interface data is not the preset format. And calling a preset format converter, and modifying the format of the first JSON interface data into a preset JSON format or a js format through the preset format converter.
And when the acquired first JSON interface data is in a JSON format or a js format, determining that the format of the first JSON interface data is a preset format. And generating a corresponding target file based on the first JSON interface data and the preset configuration file, specifically, when the format of the first JSON interface data acquired by the terminal is the preset format, acquiring the preset configuration file. The preset configuration files are as follows:
Figure BDA0002370734090000051
Figure BDA0002370734090000061
and generating a mock file corresponding to the first JSON interface data based on string and Object configuration items in the configuration file and the first JSON interface data, wherein the mock file is a simulation file of the server interface and is used as a target file corresponding to the first JSON interface data.
Step S200, debugging a preset target application program based on a target file, and receiving second JSON interface data sent by a server;
and when the terminal is based on the generated target file, acquiring a preset target application program, and debugging the data of the target application program through the target file. The method comprises the steps that a server starts a debugging task based on a preset program to debug JSON interfaces, when the completion of the debugging task is detected, second JSON interface data after the completion of debugging of the JSON interfaces are sent to a terminal, and the terminal receives the second JSON interface data sent by the server, wherein the first JSON interface data and the second JSON interface data belong to the same JSON interface. When a plurality of JSON interfaces exist in the server, the terminal debugs the data of the same application program or a plurality of application programs based on the first JSON interface data of different JSON interfaces and receives the second JSON interface data of each JSON interface.
In an embodiment, specifically referring to fig. 3, step S200 includes: substeps 201 to substep S203.
Substep S201, traversing a preset target application program, and determining a target folder in the target application program;
the method comprises the steps that when a terminal generates a corresponding target file based on first JSON interface data and a preset configuration file, a preset target application program is obtained, wherein the target application program can be a preset WEB page and the like, the target application program is traversed through a preset tool, a project code of the target application program is obtained, a target folder of the project code is determined, and the target folder is a mock folder.
Step S202, storing the target file in a target folder, and debugging the target application program;
and when the terminal determines a target folder in the target application program through a preset tool, storing the target file in the target folder for debugging the data configuration by the target application program. Illustratively, the terminal stores the target file in the target folder, and the project code of the target application program automatically reads JSON interface data of the target file in the target folder in the running process, so as to debug the data in the project code.
And step S203, if the debugging is finished, generating corresponding mock service, and sending the mock service to the server so as to receive second JSON interface data corresponding to the mock service in the server.
And after the terminal detects that the target application program is debugged based on the target file, generating corresponding mock service. Illustratively, a preset tool is called, a target file is read, so as to read the configuration rule of each configuration item in the target file, the definition in the configuration rule of each configuration item in the target file is obtained, and a mock service, i.e. a request service, of the target file is generated based on the definition in the configuration rule of each configuration item in the target file. When the server completes internal development, the current JSON interface configuration data needs to be modified, so that the current JSON interface configuration data environment responds to the internal development. And the terminal sends the mock service to the server to obtain second JSON interface data corresponding to the mock service in the server. The preset tool may be an API tool provided by using a preset node.
And step S300, determining error data of the second JSON interface data according to the target file and the second JSON interface data.
And after the terminal acquires the second JSON interface data, determining error data between the target file and the second JSON interface data by comparing the target file with the second JSON interface data. Illustratively, the second JSON interface configuration data is read to obtain an ideal value in the second JSON interface configuration data, whether an expected value in the target file is consistent with the ideal value of the second JSON interface configuration data is judged, when the expected value in the target file is inconsistent with the ideal value of the second JSON interface configuration data, the terminal extracts a field type of each configuration item in the target file, compares the field type of each configuration item with output information recorded in the second JSON interface configuration data, and compares the same type with the field, thereby determining error data between the target file and the second JSON interface configuration data. The desired value is defined by the terminal from the first JSON interface data and the desired value is defined by the server from the second JSON interface data.
In an embodiment, specifically referring to fig. 4, step S300 includes: substeps S301 to substep S302.
Step S301, respectively calculating a first numerical value of the target file and a second numerical value of the second JSON interface data based on a preset calculation program;
and when the terminal acquires the second JSON interface data, calling a preset calculation program, calculating the target file and the second JSON interface data respectively based on the preset calculation program, and calculating a first numerical value of the target file and a second numerical value of the second JSON interface data respectively. The preset calculation program is a CRC32 calculation program, and CRC 32: the CRC itself is a "redundancy check code", and CRC32 indicates that a 32bit (8 bit hexadecimal) check value is generated; since each bit of the source data block participates in the calculation when CRC32 generates a check value, a different check value is obtained even if only one bit of the data block is changed.
And the terminal respectively calculates the check value of the target file and the check value of the second JSON interface data through a preset CRC32 calculation program, takes the check value of the target file as a first numerical value of the target file, and takes the check value of the second JSON interface data as a second numerical value of the second JSON interface data.
And a substep S302, determining error data of the second JSON interface data according to the first numerical value of the target file and the second numerical value of the second JSON interface data.
And when the first numerical value of the target file is different from the second numerical value of the second JSON interface data, determining error data of the second JSON interface data. Illustratively, the terminal obtains first numerical values of each type in the target file and second numerical values of each type in the second JSON interface data, and determines error data existing in the second JSON interface data by comparing the first numerical values and the second numerical values of the same type. And comparing the target file with the data area of the second JSON interface data with error data to obtain the error data between the target file and the second JSON interface data.
In this embodiment, a target file is generated according to first JSON interface data of a receiving server, error data of second JSON interface data is determined by comparing the target file with second JSON interface data sent by the server, and a verification process of a server interface is simplified under the condition that a mock server does not need to be built and a large amount of time is used for maintaining configuration of the mock server.
Referring to fig. 5, fig. 5 is a schematic flow chart of a JSON interface verification method provided in this embodiment, and as shown in fig. 5, the JSON interface verification method includes:
step S401, receiving first JSON interface data sent by a server, and generating a corresponding target file based on the first JSON interface data;
the terminal sends a corresponding request to the server based on the user instruction, and acquires first JSON interface data corresponding to the request in the server. Illustratively, a terminal receives a user operation instruction or a user voice instruction and sends a corresponding http request, http (HyperText Transfer Protocol) is the most widely applied network Protocol on the internet, and the http request includes six request modes of GET, HEAD, PUT, DELETE, POST, and OPTIONS. And when receiving the http request sent by the terminal, the server immediately responds to and calls the interface document corresponding to the http request based on a preset protocol. Illustratively, the definition of the interface document includes the interface name: test interface, method name: get, address: /test, ref: foo, type string, go out: result, type number. And the server takes the interface document as first JSON interface data and sends the first JSON interface data to the terminal. The terminal receives first JSON interface configuration data sent by the server, generates a corresponding mock file based on the received first JSON interface data, and takes the mock file as a target file.
Step S402, debugging a preset target application program based on a target file, and receiving second JSON interface data sent by a server;
and when the terminal is based on the generated target file, acquiring a preset target application program, and debugging the data of the target application program through the target file. The method comprises the steps that a server starts a debugging task based on a preset program to debug JSON interfaces, when the completion of the debugging task is detected, second JSON interface data after the completion of data debugging of the JSON interfaces are sent to a terminal, and the terminal receives the second JSON interface data sent by the server, wherein the first JSON interface data and the second JSON interface data belong to the same JSON interface. When a plurality of JSON interfaces exist in the server, the terminal debugs the data of the same application program or a plurality of application programs based on the first JSON interface data of different JSON interfaces and receives the second JSON interface data of each JSON interface.
Step S403, respectively calculating a first numerical value of the target file and a second numerical value of the second JSON interface data based on a preset calculation program;
and when the terminal acquires the second JSON interface data, calling a preset calculation program, calculating the target file and the second JSON interface data respectively based on the preset calculation program, and calculating a first numerical value of the target file and a second numerical value of the second JSON interface data respectively. Specifically, when the preset calculation program called by the terminal is a CRC32 calculation program, CRC 32: the CRC itself is a "redundancy check code", and CRC32 indicates that a 32bit (8 bit hexadecimal) check value is generated; since each bit of the source data block participates in the calculation when CRC32 generates a check value, even if only one bit in the data block is changed, a different check value is obtained. And the terminal respectively calculates the check value of the target file and the check value of the second JSON interface data through a preset CRC32 calculation program, takes the check value of the target file as a first numerical value of the target file, and takes the check value of the second JSON interface data as a second numerical value of the second JSON interface data.
Step S404, if the first numerical value of the target file is different from the second numerical value of the second JSON interface data, calling a preset regular expression;
and the terminal judges that the first numerical value of the target file is different from the second numerical value of the second JSON interface data, and calls a preset regular expression. The regular expression is a logic formula for operating character strings, specific characters and combinations of the specific characters are predefined to form a 'regular character string', the 'regular character string' is used for expressing a filtering logic for the character strings, and the terminal takes the field type character strings of all configuration items in a target file as the regular character string of the preset regular expression in advance.
Step S405, comparing the target file with the second JSON interface data based on a preset regular expression, and determining field type error data or field missing data of the second JSON interface data.
And the terminal compares the regular character strings of the target file and the second JSON interface data through a preset regular expression to determine field type error data and field missing data of the second JSON interface data. Illustratively, the terminal regular expression compares the target file with the second JSON interface data to obtain that a certain field type in the second JSON interface data does not meet a rule character string in a preset regular expression, that is, the field type in the second JSON interface data is determined to be field type error data or field missing data.
Step S406, acquiring corresponding target data information from a target file based on field type error data or field missing data of the second JSON interface data;
and the terminal acquires corresponding target data information from the markup file through the attribute of field type error data or field missing data in the second JSON interface data. Illustratively, identification information of field type error data or field missing data is obtained, and a search is performed in the target file based on the identification information, so as to obtain corresponding target data information from the target file.
And step S407, replacing the field type error data or field missing data in the second JSON interface data with target data information.
And when the terminal acquires the target data information corresponding to the field type error data or the field missing data in the second JSON interface data, sending a replacement request to the server, and replacing the field type error data or the field missing data in the second JSON interface data of the server with the target data information to achieve the consistency with the terminal interface.
In this embodiment, the terminal receives first JSON interface data and second JSON interface data sent by the server, generates a target file based on the first JSON interface data, compares the target file with the second JSON interface data, obtains field type error data or field missing data of the second JSON interface data and corresponding target data information, and replaces the field type error data or the field missing data of the second JSON interface data with the target data information, so that not only is the process of checking the JSON interface simple, but also the terminal interface is kept consistent with the server.
Referring to fig. 6, fig. 6 is a schematic block diagram of a JSON interface verification apparatus according to an embodiment of the present disclosure.
As shown in fig. 6, the JSON interface verifying apparatus 500 includes: a receiving and generating module 501, a debugging and receiving module 502 and a determining module 503.
The receiving and generating module 501 is configured to receive first JSON interface data sent by a server, and generate a target file based on the first JSON interface data;
the debugging and receiving module 502 is used for debugging a preset target application program based on a target file and receiving second JSON interface data sent by a server;
the determining module 503 is configured to determine error data of the second JSON interface data according to the target file and the second JSON interface data.
The receiving and generating module 501 is further specifically configured to:
sending a preset GET request to a server, and receiving first JSON interface data returned by the server in response to the GET request;
and if the format of the first JSON interface data is a preset format, generating a corresponding target file based on the first JSON interface data and a preset configuration file.
The JSON interface verification apparatus 500 further includes:
detecting the format of the first JSON interface data;
if the format of the first JSON interface data is determined not to be the preset format, calling a preset format converter;
and modifying the format of the first JSON interface data into a preset format based on a preset format converter.
The debugging and receiving module 502 is further specifically configured to:
traversing a preset target application program, and determining a target folder in the target application program;
storing a target file in the target folder, and debugging a target application program;
and if the debugging is finished, generating a corresponding mock service, and sending the mock service to a server to receive second JSON interface data corresponding to the mock service in the server.
The debugging and receiving module 502 is further specifically configured to:
respectively calculating a first numerical value of the target file and a second numerical value of the second JSON interface data based on a preset calculation program;
and determining error data of the second JSON interface data according to the first numerical value of the target file and the second numerical value of the second JSON interface data.
Referring to fig. 7, fig. 7 is a schematic block diagram of another JSON interface verification apparatus according to an embodiment of the present disclosure.
As shown in fig. 7, the JSON interface verifying apparatus 600 includes: a receiving and generating module 601, a debugging and receiving module 602, a determining module 603, an obtaining module 604, and a replacing module 605.
The receiving and generating module 601 is configured to receive first JSON interface data sent by a server, and generate a target file based on the first JSON interface data;
the debugging and receiving module 602 is configured to debug a preset target application program based on a target file and receive second JSON interface data sent by a server;
the determining module 603 is configured to determine error data of the second JSON interface data according to the target file and the second JSON interface data;
the obtaining module 604 is configured to obtain corresponding target data information from the target file based on field type error data or field missing data of the second JSON interface data;
and the replacing module 605 replaces the field type error data or the field missing data in the second JSON interface data with the target data information.
It should be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the apparatus and each module and unit described above may refer to the corresponding processes in the foregoing JSON interface checking method embodiment, and are not described herein again.
The apparatus provided by the above embodiments may be implemented in the form of a computer program, which can be run on a computer device as shown in fig. 8.
Referring to fig. 8, fig. 8 is a schematic block diagram illustrating a structure of a computer device according to an embodiment of the present disclosure. The computer device may be a terminal.
As shown in fig. 8, the computer device includes a processor, a memory, and a network interface connected by a system bus, wherein the memory may include a nonvolatile storage medium and an internal memory.
The non-volatile storage medium may store an operating system and a computer program. The computer program includes program instructions that, when executed, cause a processor to perform any one of the methods for JSON interface verification.
The processor is used for providing calculation and control capability and supporting the operation of the whole computer equipment.
The internal memory provides an environment for running a computer program on a non-volatile storage medium, and the computer program, when executed by the processor, causes the processor to perform any one of the methods for JSON interface verification.
The network interface is used for network communication, such as sending assigned tasks and the like. Those skilled in the art will appreciate that the architecture shown in fig. 8 is a block diagram of only a portion of the architecture associated with the subject application, and is not intended to limit the computing device to which the subject application may be applied, and that a computing device may in particular include more or less components than those shown, or combine certain components, or have a different arrangement of components.
It should be understood that the Processor may be a Central Processing Unit (CPU), and the Processor may be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, etc. Wherein a general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Wherein, in one embodiment, the processor is configured to execute a computer program stored in the memory to implement the steps of:
receiving first JSON interface data sent by a server, and generating a corresponding target file based on the first JSON interface data;
debugging a preset target application program based on the target file, and receiving second JSON interface data sent by the server;
and determining error data of the second JSON interface data according to the target file and the second JSON interface data.
In one embodiment, when the processor receives first JSON interface data sent by a server and generates a target file based on the first JSON interface data, the following is specifically implemented:
sending a preset GET request to a server, and receiving first JSON interface data returned by the server in response to the GET request;
and if the format of the first JSON interface data is a preset format, generating a corresponding target file based on the first JSON interface data and a preset configuration file.
In one embodiment, when the processor implements receiving the first JSON interface data sent by the server in response to the GET request, the following is specifically implemented:
detecting the format of the first JSON interface data;
if the format of the first JSON interface data is determined not to be the preset format, calling a preset format converter;
and modifying the format of the first JSON interface data into a preset format based on a preset format converter.
In one embodiment, when the processor implements debugging of a preset target application program based on a target file and receives second JSON interface data sent by a server, the following is specifically implemented:
traversing a preset target application program, and determining a target folder in the target application program;
storing a target file in the target folder, and debugging a target application program;
and if the debugging is finished, generating a corresponding mock service, and sending the mock service to a server to receive second JSON interface data corresponding to the mock service in the server.
In one embodiment, when the processor determines the error data of the second JSON interface data according to the target file and the second JSON interface data, the following is specifically implemented:
respectively calculating a first numerical value of the target file and a second numerical value of the second JSON interface data based on a preset calculation program;
and determining error data of the second JSON interface data according to the first numerical value of the target file and the second numerical value of the second JSON interface data.
In an embodiment, when the processor determines the error data of the second JSON interface data according to the first numerical value of the target file and the second numerical value of the second JSON interface data, the following is specifically implemented:
if the first numerical value of the target file is different from the second numerical value of the second JSON interface data, calling a preset regular expression;
and comparing the target file with the second JSON interface data based on a preset regular expression, and determining field type error data or field missing data of the second JSON interface data.
In one embodiment, after the processor determines that the field type of the second JSON interface data is wrong or the field of the second JSON interface data is missing, the processor specifically implements:
acquiring corresponding target data information from the target file based on the field type error data or field missing data of the second JSON interface data;
and replacing the field type error data or field missing data in the second JSON interface data with the target data information.
Embodiments of the present application further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, where the computer program includes program instructions, and a method implemented when the program instructions are executed may refer to various embodiments of the JSON interface verification method in the present application.
The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, for example, a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the computer device.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A JSON interface checking method is characterized by comprising the following steps:
receiving first JSON interface data sent by a server, and generating a corresponding target file based on the first JSON interface data;
debugging a preset target application program based on the target file, and receiving second JSON interface data sent by the server;
and determining error data of the second JSON interface data according to the target file and the second JSON interface data.
2. The method for checking JSON interface of claim 1, wherein the receiving first JSON interface data sent by a server and generating a corresponding target file based on the first JSON interface data comprises:
sending a preset GET request to a server, and receiving first JSON interface data returned by the server in response to the GET request;
and if the format of the first JSON interface data is a preset format, generating a corresponding target file based on the first JSON interface data and a preset configuration file.
3. The method for JSON interface validation as claimed in claim 2, wherein after receiving the first JSON interface data returned by the server in response to the GET request, further comprising:
detecting the format of the first JSON interface data;
if the format of the first JSON interface data is determined not to be a preset format, calling a preset format converter;
and modifying the format of the first JSON interface data into the preset format based on the preset format converter.
4. The method for checking JSON interface of claim 1, wherein the debugging a preset target application based on the target file and receiving second JSON interface data sent by the server, comprises:
traversing a preset target application program, and determining a target folder in the target application program;
storing the target file in the target folder, and debugging the target application program;
and if the debugging is finished, generating a corresponding mock service, and sending the mock service to the server to receive second JSON interface data corresponding to the mock service in the server.
5. The method for checking JSON interface according to any one of claims 1-4, wherein the determining the error data of the second JSON interface data according to the target file and the second JSON interface data comprises:
respectively calculating a first numerical value of the target file and a second numerical value of the second JSON interface data based on a preset calculation program;
and determining error data of the second JSON interface data according to the first numerical value of the target file and the second numerical value of the second JSON interface data.
6. The method for checking JSON interface of claim 5, wherein the determining the error data of the second JSON interface data according to the first value of the target file and the second value of the second JSON interface data comprises:
if the first numerical value of the target file is different from the second numerical value of the second JSON interface data, calling a preset regular expression;
and comparing the target file with the second JSON interface data based on the preset regular expression, and determining field type error data or field missing data of the second JSON interface data.
7. The method for checking JSON interface of claim 6 wherein, after determining that the second JSON interface data has a field type of error data or a field of missing data, further comprising:
acquiring corresponding target data information from the target file based on field type error data or field missing data of the second JSON interface data;
and replacing the field type error data or field missing data in the second JSON interface data with the target data information.
8. A JSON interface verification device is characterized by comprising:
the receiving and generating module is used for receiving first JSON interface data sent by a server and generating a target file based on the first JSON interface data;
the debugging and receiving module is used for debugging a preset target application program based on the target file and receiving second JSON interface data sent by the server;
and the determining module is used for determining the error data of the second JSON interface data according to the target file and the second JSON interface data.
9. A computer device, characterized in that the computer device comprises: memory, a processor and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the method of JSON interface checking according to any of claims 1 to 7.
10. A computer-readable storage medium, having stored thereon a computer program which, when executed by a processor, carries out the steps of the method of JSON interface checking as claimed in any one of claims 1 to 7.
CN202010051261.1A 2020-01-16 2020-01-16 JSON interface verification method, device and equipment and computer readable storage medium Pending CN111309593A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010051261.1A CN111309593A (en) 2020-01-16 2020-01-16 JSON interface verification method, device and equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010051261.1A CN111309593A (en) 2020-01-16 2020-01-16 JSON interface verification method, device and equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN111309593A true CN111309593A (en) 2020-06-19

Family

ID=71144884

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010051261.1A Pending CN111309593A (en) 2020-01-16 2020-01-16 JSON interface verification method, device and equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN111309593A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111897687A (en) * 2020-08-19 2020-11-06 百度时代网络技术(北京)有限公司 Interface checking method, device, equipment and storage medium
CN112052037A (en) * 2020-09-07 2020-12-08 北京达佳互联信息技术有限公司 Application software development method, device, equipment and medium
CN112363935A (en) * 2020-11-11 2021-02-12 平安普惠企业管理有限公司 Data joint debugging method and device, electronic equipment and storage medium
CN112579205A (en) * 2020-12-24 2021-03-30 平安普惠企业管理有限公司 Configuration file checking method and device, computer equipment and storage medium
CN112733199A (en) * 2020-12-28 2021-04-30 北京极豪科技有限公司 Data processing method and device, electronic equipment and readable storage medium
CN112799673A (en) * 2021-01-19 2021-05-14 烽火通信科技股份有限公司 Network protocol data checking method and device
CN113467780A (en) * 2021-06-30 2021-10-01 北京达佳互联信息技术有限公司 Data acquisition method and device, electronic equipment and storage medium

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111897687A (en) * 2020-08-19 2020-11-06 百度时代网络技术(北京)有限公司 Interface checking method, device, equipment and storage medium
CN111897687B (en) * 2020-08-19 2024-04-26 百度时代网络技术(北京)有限公司 Interface verification method, device, equipment and storage medium
CN112052037A (en) * 2020-09-07 2020-12-08 北京达佳互联信息技术有限公司 Application software development method, device, equipment and medium
CN112363935A (en) * 2020-11-11 2021-02-12 平安普惠企业管理有限公司 Data joint debugging method and device, electronic equipment and storage medium
CN112579205A (en) * 2020-12-24 2021-03-30 平安普惠企业管理有限公司 Configuration file checking method and device, computer equipment and storage medium
CN112733199A (en) * 2020-12-28 2021-04-30 北京极豪科技有限公司 Data processing method and device, electronic equipment and readable storage medium
CN112799673A (en) * 2021-01-19 2021-05-14 烽火通信科技股份有限公司 Network protocol data checking method and device
CN112799673B (en) * 2021-01-19 2022-03-25 烽火通信科技股份有限公司 Network protocol data checking method and device
CN113467780A (en) * 2021-06-30 2021-10-01 北京达佳互联信息技术有限公司 Data acquisition method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111309593A (en) JSON interface verification method, device and equipment and computer readable storage medium
CN108415832B (en) Interface automation test method, device, equipment and storage medium
CN109474578B (en) Message checking method, device, computer equipment and storage medium
CN111428462B (en) Communication protocol template construction method and terminal equipment
WO2019227573A1 (en) Collaborative office data stream processing method and apparatus, computer device, and storage medium
CN111552627A (en) User interface testing method and device, storage medium and computer equipment
CN110351325B (en) Data processing method and related equipment
CN109445837B (en) Application program publishing method and device
WO2020192141A1 (en) Method and device for simulating interface, computer apparatus, and storage medium
CN104679500B (en) Method and device for realizing automatic generation of entity class
CN110955409B (en) Method and device for creating resources on cloud platform
CN111596902B (en) Method, device, equipment and storage medium for building front-end and back-end development framework
CN108776587B (en) Data acquisition method and device, computer equipment and storage medium
CN114741070A (en) Code generation method and device, electronic equipment and storage medium
CN111506579B (en) Method, program and equipment for generating intelligent contract code
CN115599359A (en) Code generation method, device, equipment and medium
CN111723019A (en) Interface debugging method and system
CN111078213B (en) Code generation method and code generation device
CN117493309A (en) Standard model generation method, device, equipment and storage medium
CN112699027A (en) Interface testing method, device, equipment and readable storage medium
CN110233842B (en) Request verification method and related device
CN116414689A (en) Interface parameter verification method and system based on reflection mechanism
CN114579466A (en) Method, device, equipment and medium for constructing test case and code test
CN111651362A (en) Test case generation method and device, storage medium and computer equipment
CN112417012A (en) Data processing method and system

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