Data processing method and device

By obtaining the verification rules and data types of data items, checking for nested and non-necked data items, the problem of unreliable verification of complex data types in the prior art is solved, and the reliability of data verification is improved Sex and efficiency.

CN111897833BActive Publication Date: 2025-02-18NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010805786.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-12
Publication Date
2025-02-18
Estimated Expiration
2040-08-12

AI Technical Summary

Technical Problem

The prior art is difficult to effectively verify complex data types, such as list and key-value pairs, resulting in low reliability of data verification.

Method used

By obtaining the verification rules and data types corresponding to the data items, checking them for nested and non-necked types, including judging null values, data type matching and nested data structure verification.

Benefits of technology

Effective verification of complex data types is realized, the reliability and efficiency of data verification is improved, and errors caused by the inability to verify nested data items are avoided.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111897833B_ABST
    Figure CN111897833B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a data processing method and device, the method comprising: obtaining a first verification rule corresponding to a first key-value pair, the first key-value pair being any key-value pair in the data to be verified, the first key-value pair comprising a first keyword and a first value. Obtaining a data type of the first value, the data type being a nested type or a non-nested type. Verifying the first value according to the first verification rule and the data type to obtain a verification result. By obtaining the first verification rule corresponding to the first key-value pair, and obtaining the data type of the first value, the first value of the nested type and the first value of the non-nested type can be verified according to the first verification rule, thereby avoiding the situation where the first value of the nested type cannot be verified, and effectively ensuring the reliability of data verification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to computer technology, and more particularly to a data processing method and device. Background Art

[0002] The user may submit data through a client or a World Wide Web (WEB), so that the client, WEB, or server verifies the submitted data.

[0003] In the related art, verification rules can be pre-set for the data, and the client, WEB terminal, or server can determine whether the data meets the conditions based on the verification rules, for example, whether the size of the data is within a preset range, whether the length of the data meets the preset length, etc.

[0004] However, when the data is more complex, for example, when the data is a list, a key-value pair, or the like, it is impossible to verify the data according to the verification rules, resulting in low reliability of data verification. Summary of the invention

[0005] The embodiments of the present application provide a data processing method and device to overcome the problem of low reliability of data verification.

[0006] In a first aspect, an embodiment of the present application provides a data processing method, including:

[0007] Obtain a first verification rule corresponding to a first key-value pair, where the first key-value pair is any key-value pair in the data to be verified, and the first key-value pair includes a first keyword and a first value;

[0008] Obtaining a data type of the first value, where the data type is a nested type or a non-nested type;

[0009] The first value is verified according to the first verification rule and the data type to obtain a verification result.

[0010] In one possible design, the nested type includes at least one of the following types: a list, a key-value pair;

[0011] The non-nested type includes at least one of the following types: number, string.

[0012] In a possible design, verifying the first value according to the first verification rule and the data type to obtain a verification result includes:

[0013] Determine whether the first value is empty;

[0014] If yes, if the first verification rule allows the value to be empty, then the verification result is determined to be a successful verification; if the first verification rule does not allow the value to be empty, then the verification result is determined to be a failed verification;

[0015] If not, determine whether the data type of the first value is one of the preset types in the first verification rule. If it is not one of the preset types, determine the verification result as verification failure. If it is one of the preset types, determine the verification result based on the data type of the first value.

[0016] In a possible design, the data type of the first value is a nested type; and determining the verification result according to the data type of the first value includes:

[0017] If the nested type is a list, the first value is the first list, and for each element in the first list, the above operation of determining whether the first value is empty is repeatedly performed to obtain a verification result for each element in the first list; or

[0018] If the nested type is a key-value pair, the first value is a second key-value pair, the second key-value pair includes a second keyword and a second value, and the second value is verified according to the second keyword and the check table corresponding to the data to be verified to obtain a verification result.

[0019] In a possible design, verifying the second value according to the second keyword and a check table corresponding to the data to be verified to obtain a verification result includes:

[0020] Determine whether there is a second verification rule corresponding to the second keyword in the check table corresponding to the data to be verified;

[0021] If so, the second value is verified according to the second verification rule and the data type of the second value to obtain a verification result.

[0022] If not, the first key-value pair is discarded or ignored.

[0023] In a possible design, the data type of the first value is a non-nested type; and determining the verification result according to the data type of the first value includes:

[0024] Determine whether the data type of the first value is a string;

[0025] If so, when the length of the first value is not within a preset length range, the verification result is determined to be a verification failure.

[0026] If not, a check function is obtained, and the data type is checked by the check function to obtain the check result.

[0027] In a second aspect, an embodiment of the present application provides a data processing device, including:

[0028] An acquisition module, configured to acquire a first verification rule corresponding to a first key-value pair, wherein the first key-value pair is any key-value pair in the data to be verified, and the first key-value pair includes a first keyword and a first value;

[0029] The acquisition module is further used to acquire a data type of the first value, where the data type is a nested type or a non-nested type;

[0030] A verification module is used to verify the first value according to the first verification rule and the data type to obtain a verification result.

[0031] In one possible design, the nested type includes at least one of the following types: a list, a key-value pair;

[0032] The non-nested type includes at least one of the following types: number, string.

[0033] In a possible design, the verification module is specifically used to:

[0034] Determine whether the first value is empty;

[0035] If yes, if the first verification rule allows the value to be empty, then the verification result is determined to be a successful verification; if the first verification rule does not allow the value to be empty, then the verification result is determined to be a failed verification;

[0036] If not, determine whether the data type of the first value is one of the preset types in the first verification rule. If it is not one of the preset types, determine the verification result as verification failure. If it is one of the preset types, determine the verification result based on the data type of the first value.

[0037] In a possible design, the data type of the first value is a nested type;

[0038] The verification module is specifically used for:

[0039] If the nested type is a list, the first value is the first list, and for each element in the first list, the above operation of determining whether the first value is empty is repeatedly performed to obtain a verification result for each element in the first list; or

[0040] If the nested type is a key-value pair, the first value is a second key-value pair, the second key-value pair includes a second keyword and a second value, and the second value is verified according to the second keyword and the check table corresponding to the data to be verified to obtain a verification result.

[0041] In a possible design, the verification module is specifically used to:

[0042] Determine whether there is a second verification rule corresponding to the second keyword in the check table corresponding to the data to be verified;

[0043] If so, the second value is verified according to the second verification rule and the data type of the second value to obtain a verification result.

[0044] If not, the first key-value pair is discarded or ignored.

[0045] In a possible design, the data type of the first value is a non-nested type;

[0046] The verification module is specifically used for:

[0047] Determine whether the data type of the first value is a string;

[0048] If so, when the length of the first value is not within a preset length range, the verification result is determined to be a verification failure.

[0049] If not, a check function is obtained, and the data type is checked by the check function to obtain the check result.

[0050] In a third aspect, an embodiment of the present application provides a data processing device, including:

[0051] Memory, used to store programs;

[0052] A processor is used to execute the program stored in the memory. When the program is executed, the processor is used to execute the method described in the first aspect and any one of the various possible designs of the first aspect.

[0053] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on a computer, enables the computer to execute the method described in the first aspect and any one of the various possible designs of the first aspect.

[0054] An embodiment of the present application provides a data processing method and device, the method comprising: obtaining a first verification rule corresponding to a first key-value pair, the first key-value pair being any key-value pair in the data to be verified, the first key-value pair comprising a first keyword and a first value. Obtaining a data type of the first value, the data type being a nested type or a non-nested type. Verifying the first value according to the first verification rule and the data type to obtain a verification result. By obtaining the first verification rule corresponding to the first key-value pair, and obtaining the data type of the first value, the first value of the nested type and the first value of the non-nested type can be verified according to the first verification rule, thereby avoiding the situation where the first value of the nested type cannot be verified, and effectively ensuring the reliability of data verification. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0056] Figure 1 A system diagram of a data processing method provided in an embodiment of the present application;

[0057] Figure 2 A schematic diagram of the client receiving data submitted by the user provided by this application;

[0058] Figure 3 A schematic diagram of a WEB terminal receiving data submitted by a user provided in an embodiment of the present application;

[0059] Figure 4 A flowchart of a data processing method provided in one embodiment of the present application;

[0060] Figure 5 A schematic diagram of implementing verification of a first value provided in an embodiment of the present application;

[0061] Figure 6 A schematic diagram of implementing a list as the first value provided in an embodiment of the present application;

[0062] Figure 7 A single-layer nested schematic diagram of a key-value pair as the first value provided in an embodiment of the present application;

[0063] Figure 8 A schematic diagram of a multi-layer nesting of a key-value pair in which the first value is provided in an embodiment of the present application;

[0064] Fig. 9 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;

[0065] Fig.10 A schematic diagram of the hardware structure of a data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0066] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0067] Combine the following Figure 1 Describe the application scenarios involved in this application. Figure 1 A system diagram of a data processing method provided in an embodiment of the present application.

[0068] like Figure 1 As shown, the system includes: a client 101, a WEB terminal 102, a server 103 and a database 104.

[0069] Among them, the client 101 and the WEB end 102 can receive data submitted by the user, among which the WEB end 102 can, for example, receive data submitted by the user through a web page, and the client can, for example, receive data submitted by the user through an application (Application, APP), firmware, etc., in non-web page forms.

[0070] In this embodiment, the client 101 or the WEB end 102 can first verify the data submitted by the user. If the verification of the client 101 or the WEB end 102 fails, a prompt message indicating that the current data is illegal can be sent to the user. If the verification of the client 101 or the WEB end 102 passes, the data submitted by the user will be sent to the server 103, thereby effectively reducing the burden on the server 103.

[0071] After the server 103 receives the data submitted by the user, the server 103 may verify the data submitted by the user again and return the verification result to the client 101 or the WEB end 102, wherein both the client or the WEB end and the server perform detection to ensure the reliability of the verification result.

[0072] See also Figure 1 It can be determined that the server 103 corresponds to a database 104. In this embodiment, the database 104 may store verification rules, for example, referring to step 0, a check list is pre-stored, wherein the check list may include verification rules for at least one keyword.

[0073] Alternatively, relevant data of the client or the WEB terminal may be stored. The present embodiment does not limit the specific content stored in the database 104. All content that the server 103 needs to store may be stored in the database 104 of the present embodiment.

[0074] In this embodiment, the client 101 or the WEB terminal 102 interacts with the server 103, wherein the interaction may be, for example, through a wired network, which may include, for example, a coaxial cable, a twisted pair, and an optical fiber, etc., wherein the interaction may also be, for example, a wireless network, which may be a 2G network, a 3G network, a 4G network, or a 5G network, a wireless fidelity (Wireless Fidelity, WIFI for short) network, etc. The embodiment of the present application does not limit the specific type or form of interaction, as long as it can realize the function of interaction between the server and the terminal.

[0075] The following is a brief description of the interaction process:

[0076] After receiving the data to be verified submitted by the user, the WEB end can execute step 1 to request a checklist from the server. Then the server can execute step 2 to request the checklist from the database. The database returns the checklist to the server, and the server returns the checklist to the WEB end. The WEB end can then verify the data to be verified based on the obtained checklist.

[0077] Similar to the implementation method of the client, after receiving the data to be verified submitted by the user, the client can execute step 5 to request a checklist from the server, and can execute step 5 to receive the checklist returned by the server, so that the client can verify the data to be verified according to the obtained checklist.

[0078] And the client and / or the server may also send the data to be verified to the server, so that the server verifies the data to be verified according to the checklist.

[0079] The above combination Figure 1 The system diagram of data verification is introduced, wherein the data submitted by the user that needs to be verified may be, for example, account data, password data, filled-in questionnaire data, etc. The following introduces a possible implementation method for the client to receive the data submitted by the user and the WEB end to receive the data submitted by the user, combining with the scenario where the user logs in to a website or an application.

[0080] Figure 2 A schematic diagram of the client receiving data submitted by the user provided in this application. Figure 3 A schematic diagram of a WEB terminal receiving data submitted by a user provided in an embodiment of the present application.

[0081] In one possible implementation, see Figure 2 , assuming that the current user opens a client of an application, enters the account name and password through the client, and clicks Figure 2 The "Login" control shown in the figure, the client can now receive the account name data and password data submitted by the user, and can subsequently perform corresponding verification on the account name data and password data.

[0082] In another possible implementation, see Figure 3 , assuming that the user currently opens the login page of the website AAA, enters the account name and password on the login page of the website AAA, and clicks Figure 3 The "Login" control shown in the figure, the WEB end can now receive the account name data and password data submitted by the user, and can subsequently perform corresponding verification on the account name data and password data.

[0083] Above Figure 2 and Figure 3 This is explained in conjunction with a login scenario. In actual implementation, there are multiple possible implementations of the data to be verified submitted by the user. This embodiment does not limit the specific content and type of the data.

[0084] Based on the above introduction, the following is an introduction to the implementation method of verifying data in the prior art:

[0085] In the current human-computer interaction process, the server will receive a large amount of data submitted by users, and the server needs to verify the data submitted by these users.

[0086] When verifying the data submitted by the user, in one possible implementation, a large amount of code written for the data structure of the data to be verified can be run on the server to verify whether the data submitted by the user is legal. If the data structure is very large, then the server needs to run a lot of code, and when the data structure changes, the code must also change accordingly.

[0087] For example, for a questionnaire system, the questionnaires created by different users are different. In the implementation of writing code, it is necessary to write a checking program for each questionnaire, which will result in a very large workload for verifying the data.

[0088] In another possible implementation, a configuration checklist can be used to verify the data, wherein the checklist is a key-value pair object written by the data checker according to the data format. The key-value pair object is also called a key-value object, which is a data structure. Its storage method consists of one or more key-value pairs. A key value consists of a key (also called a keyword) and a value. The stored value can be retrieved according to the keyword.

[0089] Taking the questionnaire introduced above as an example, if the checklist method is used for data verification, it is only necessary to generate a checklist for the questionnaire system. The program can read the contents of the checklist and match it with the data submitted through the questionnaire to verify the data. There is no need to write a separate checklist for each questionnaire, which can effectively reduce the workload of data verification.

[0090] In a possible implementation, the key-value pair may have only one level, that is, the value in the key-value pair may be a basic data type such as a number or a string.

[0091] In another possible implementation, the key-value pair may be nested in multiple levels, that is, the value in the key-value pair may be a list, a key-value pair or other data types. For example, there is a key-value1, and the value in the key-value1 is another key-value2.

[0092] The current implementation cannot verify key-value pairs that are nested at multiple levels, resulting in low reliability of data verification.

[0093] Based on the problems in the prior art, the present application provides a data processing method and device to implement the verification of key-value pairs nested in multiple levels. The data processing method provided by the present application is described below in conjunction with specific embodiments.

[0094] Figure 4 This is a flowchart of a data processing method provided in one embodiment of the present application. It can be understood that: Figure 4 The execution subject of the embodiment may be a server, a WEB terminal, or a client, depending on which component is currently verifying the data to be verified.

[0095] like Figure 4 As shown, the method includes:

[0096] S401. Obtain a first verification rule corresponding to a first key-value pair, where the first key-value pair is any key-value pair in the data to be verified, and the first key-value pair includes a first keyword and a first value.

[0097] In this embodiment, the data to be verified may include multiple key-value pairs. Taking the login scenario introduced above as an example, the current data to be verified may include account name data and password data, wherein the key-value pair corresponding to the account name data may be, for example, "ID-Xiao Li", and the key-value pair corresponding to the password data may be, for example, "password-516". For the key-value pair "ID-Xiao Li", the key is the ID and the value is Xiao Li, and for the key-value pair "password-516", the key is the password and the value is 516.

[0098] Any key-value pair in the data to be verified is used as the first key-value pair in this embodiment to obtain a first verification rule corresponding to the first key-value pair, wherein the first key-value pair includes a first keyword and a first value.

[0099] In this embodiment, a checklist may be pre-set, for example, a technician may generate the checklist, or a non-technical person may generate the checklist using a WEB component, the generated checklist may be stored in a database, and an inspection identifier may be generated and bound to the checklist.

[0100] Among them, multiple verification rules can be set in the check table, and each verification rule can correspond to its own keyword, which is used to indicate that the current verification rule is a verification rule set for a certain key-value pair. In a possible implementation method of obtaining the first verification rule corresponding to the first key-value pair, the first keyword in the first key-value pair can be matched with each verification rule to obtain the first verification rule corresponding to the first key-value pair.

[0101] Assuming that there are currently verification rule 1 and verification rule 2, the keyword corresponding to verification rule 1 is ID, and the keyword corresponding to verification rule 2 is password, and assuming that the current first key-value pair is "ID-Xiao Li", you can match the keyword ID and the verification rule in the first key-value pair to obtain verification rule 1 corresponding to "ID-Xiao Li".

[0102] Among them, verification rule 1 may include, for example, whether the length of the character string is less than a preset length, whether there are characters other than preset character types, etc. In this embodiment, the specific implementation method of the first verification rule can be selected according to actual needs, and this embodiment does not limit this.

[0103] S402: Obtain a data type of the first value, where the data type is a nested type or a non-nested type.

[0104] The first key-value pair may be, for example, a key-value pair with only one layer, and the data type of the first value in the first key-value pair may be a non-nested type, wherein the non-nested type may include at least one of the following types: number, string.

[0105] The above-mentioned numeric types may be, for example, basic data types such as int (integer), long (long integer), short (short integer), float (single precision), double (double precision), byte (bit), etc., and the character string may be the data type string.

[0106] Alternatively, the first key-value pair may also be a multi-layer nested key-value pair, then the data type of the first value in the first key-value pair may be a nested type, wherein the nested type may include at least one of the following types: list, key-value pair, wherein the list may be of data type list, and the key-value pair may be of data type key-value.

[0107] S403: Verify the first value according to the first verification rule and the data type to obtain a verification result.

[0108] The first verification rule in this embodiment is used to verify the first value, and in this embodiment, different verification methods may be used for the first value of the nested type and the first value of the non-nested type. Therefore, the first value may be verified according to the first verification rule and the data type, and the obtained verification result may be, for example, a successful verification or a failed verification.

[0109] In one possible implementation, for a first value of a non-nested type, the first value can be directly checked according to a first check rule, for example, to check whether the data type of the first value meets a preset type, or to check whether the data length of the first value meets a preset length, etc.

[0110] In another possible implementation, for the first value of the nested type, because the current first value may be a list or a key-value pair, for example, for the first value of the key-value pair, the above operation can be recursively performed to obtain the second verification rule corresponding to the key-value pair of the first value, and the second verification rule is used to verify the second value in the key-value pair of the first value to obtain the preset rule. If the second value is also a key-value pair, the above recursive process can be continued. Continue to execute the above method of obtaining verification rules until the final non-nested type value is verified.

[0111] Alternatively, when the corresponding verification rule cannot be obtained, the current first key-value pair can be discarded.

[0112] Therefore, the embodiments of the present application can effectively implement verification of the first value for both the nested type and the non-nested type, thereby effectively ensuring the reliability of data verification.

[0113] The data processing method provided in the embodiment of the present application includes: obtaining a first verification rule corresponding to a first key-value pair, the first key-value pair being any key-value pair in the data to be verified, and the first key-value pair including a first keyword and a first value. Obtaining a data type of the first value, the data type being a nested type or a non-nested type. Verifying the first value according to the first verification rule and the data type to obtain a verification result. By obtaining the first verification rule corresponding to the first key-value pair and obtaining the data type of the first value, the first value of the nested type and the first value of the non-nested type can be verified according to the first verification rule, thereby avoiding the situation where the first value of the nested type cannot be verified, and effectively ensuring the reliability of data verification.

[0114] Based on the above embodiments, the implementation method of verifying the first value according to the first verification rule and the data type is introduced below in combination with specific embodiments. In the present application, the first value can be verified for both nested types and non-nested types, wherein some general formal verifications can be performed before differentiating the first value of the nested type and the first value of the non-nested type.

[0115] Combine the following Figure 5-Figure 8 Introduce a possible implementation method of checking the first value, Figure 5 A schematic diagram of implementing verification of a first value provided in an embodiment of the present application, Figure 6 The first value provided in the embodiment of the present application is a schematic diagram of a list. Figure 7 A single-layer nested schematic diagram of a key-value pair as the first value provided in an embodiment of the present application, Figure 8 A schematic diagram of multi-layer nesting in which the first value provided in an embodiment of the present application is a key-value pair.

[0116] like Figure 5 As shown, the method includes:

[0117] S501. Determine whether the first value is empty. If so, execute S502; if not, execute S505.

[0118] In this embodiment, the first value in the first key-value pair may be empty, that is, the value in the key-value may have no data.

[0119] When the first value is empty, there is no need to perform a series of data type processing on the first value, so it can be determined first whether the first value is empty.

[0120] S502: Determine whether the first verification rule allows the value to be empty. If so, execute S503; if not, execute S504.

[0121] If the first value is empty, it is necessary to determine whether the first verification rule allows the value to be empty, that is, whether the data with an empty value is legal, based on the first verification rule.

[0122] In a possible implementation, the first value is empty, but the first verification rule does not allow the value to be empty, and then it can be determined that the verification result for the first value is a verification failure.

[0123] For example, for the data submitted by the user in the login scenario, the account name and password are both necessary data, so the first verification rule can be set to: for the key-value pair corresponding to the account name data, its value is not allowed to be empty; and for the key-value pair corresponding to the password data, its value is not allowed to be empty.

[0124] And assuming that in the data submitted by the current user, the first value of the first key-value pair corresponding to the password data is empty, it can be determined that the verification has failed. In a possible implementation, a prompt message can be displayed to inform the user that the password is not allowed to be empty.

[0125] In another possible implementation, the first value is empty, but the first verification rule allows the value to be empty, then it can be determined that the verification result for the first value is successful.

[0126] For example, for a questionnaire, there may be optional items in the questionnaire, wherein the optional items are items that the user may fill in or not fill in, so the first verification rule may be set such that the value of the key-value pair corresponding to the optional item is allowed to be empty.

[0127] And assume that in the data submitted by the current user, the first value of the first key-value pair corresponding to the optional item is empty. Because this is allowed and there is no need to check the empty value, it can be determined that the verification is successful.

[0128] S503: Determine that the verification result is successful.

[0129] S504: Determine that the verification result is a verification failure.

[0130] In this embodiment, the verification result may be a verification success or a verification failure.

[0131] In the following steps corresponding to the verification results, the corresponding verification success or verification failure situations are described in detail, so S503 and S504 are not specially described here.

[0132] S505: Determine whether the data type of the first value is one of the preset types in the first verification rule; if not, execute S504; if yes, execute S506.

[0133] If the first value is not empty, it indicates that there is data in the first value, and then it can be determined whether the data type of the first value is one of the preset types in the first verification rule.

[0134] Among them, the preset type of the first verification rule includes the allowed data type of the first value. Taking the questionnaire as an example, assuming that the user is required to fill in age information in the questionnaire, the keyword in the key-value pair corresponding to the age information can be age, and the value can be the age filled in by the user.

[0135] Assuming that the allowed data type for age is number, the preset type in the first verification rule may include, for example, at least one of the following: int, long, short, float, double.

[0136] In one possible implementation, when the first value in the first key-value pair corresponding to the age information is not one of the preset types introduced above, for example, the age data filled in and submitted by the user is "female", then the data type of the current first value is a string, which is not one of the preset types. Therefore, the first value is an unallowed type, and it can be determined that the test result corresponding to the first value is a test failure.

[0137] In a possible implementation, when the verification fails, the user may be prompted with the data type allowed by the current first value.

[0138] S506: Determine whether the data type of the first value is a nested type. If so, execute S507; if not, execute S512.

[0139] In another possible implementation, if the data type of the first value is one of the preset types in the first verification rule, it indicates that the data type of the current first value is allowed, and then it can be determined whether the data type of the first value is a nested type, so that the non-nested first value and the nested first value can be processed differently.

[0140] S507. Determine whether the nested type is a list. If so, execute S508; if not, execute S509.

[0141] In one possible implementation, if the data type of the first value is a nested type, different processing methods can be used for lists and key-value pairs in this embodiment. Therefore, it can be determined whether the nested type is a list to determine the specific nested type of the current first value.

[0142] Alternatively, it is also possible to determine whether the nested type is a key-value pair. This embodiment does not limit the specific implementation of the determination, as long as it is possible to determine the specific nested type of the first value. Alternatively, it is possible to directly perform corresponding operations based on the data type of the first value without making any determination.

[0143] In one possible implementation, if the nested type is determined to be a list, the first value may be a first list, wherein each element in the first list is a number or a string, that is, a non-nested type, and therefore it may be determined first whether the length of the list is within a preset length range.

[0144] S508: Determine whether the length of the list is within a preset length range. If so, repeat S501 for each element in the first list. If not, execute S504.

[0145] In one possible implementation, if it is determined that the length of the list is within a preset length range, it can be determined that the length of the list meets the requirements. For each element in the first list, the above series of operations of determining whether the first value is empty are repeated to obtain the verification results of each element. For example, when the verification result of any element is a verification failure, it can be determined that the verification result of the first value is a verification failure.

[0146] Combine the following Figure 6 For instructions, see Figure 6 , assuming that there is currently a first key-value pair, in which the first keyword is A and the first value is Figure 6 The first list 601 is shown, wherein the first list 601 includes 4 elements, which are numbers 1, 2, 3, and 4 respectively.

[0147] Then, the above S510 may be executed for the numbers 1, 2, 3, and 4 respectively, so as to obtain the verification results of the respective numbers, and the verification results of the first value may be determined according to the verification results of the respective numbers.

[0148] In another possible implementation, if it is determined that the length of the list is not within a preset length range, it can be determined that the length of the list does not meet the requirement, and thus it can be determined that the verification has failed.

[0149] S509, determine whether there is a second verification rule corresponding to the second keyword in the check table corresponding to the data to be verified, if yes, execute S510, if not, execute S511.

[0150] In another possible implementation, if it is determined that the nested type is not a list, it can be determined that the nested type is a key-value pair, and the first value can be a second key-value pair, wherein the second key-value pair includes a second keyword and a second value.

[0151] See for example Figure 7 , assuming that there is currently a first key-value pair, where the first keyword is B and the first value is Figure 7 The second key-value pair 710 is shown in , wherein the second keyword of the second key-value pair 710 is C, and the second value is 233.

[0152] The corresponding inspection rules for different key-value pairs may be different. For example, the inspection rules for the key-value pair of name and the inspection rules for the key-value pair of age must be different.

[0153] In this embodiment, the check table corresponding to the data to be checked stores a check rule corresponding to at least one keyword. At this time, the first value needs to be checked, that is, the second key-value pair needs to be checked. Therefore, it can be determined whether there is a second check rule corresponding to the second keyword in the check table corresponding to the data to be checked.

[0154] It should be noted that when the nested type is a list, there is usually only one level of nesting, that is, the first value is the first list, and the first list includes at least one non-nested type of data; however, when the nested type is a key-value pair, there may be multiple levels of nesting, where Figure 8 It shows a 4-layer nested implementation, where:

[0155] The first keyword of the first key-value pair is D, and the first value is the second key-value pair;

[0156] The second keyword of the second key-value pair is E, and the second value is the third key-value pair;

[0157] The third keyword of the third key-value pair is F, and the third value is the fourth key-value pair;

[0158] The fourth keyword of the fourth key-value pair is G, and the fourth value is 233.

[0159] Figure 8 The example in the figure shows a 4-layer nested implementation of key-value pairs. In the actual implementation process, the number of nested layers of the first key-value pair can be selected according to actual needs. This embodiment does not limit this. In a possible implementation, a list can be nested in the multiple layers of nested first key-value pairs, such as Figure 8 The third value of the third key-value pair in can be, for example, a list, which can be selected according to actual needs.

[0160] S510. Verify the second value according to a second verification rule and a data type of the second value to obtain a verification result.

[0161] In a possible implementation, if there is a second verification rule corresponding to the second keyword, the second value can be verified according to the second verification rule and the data type of the second value to obtain a verification result.

[0162] Among them, the implementation method of verifying the second value according to the second verification rule and the data type of the second value to obtain the verification result is the same as the implementation method of verifying the first value according to the first verification rule and the data type to obtain the verification result introduced in this embodiment, and is also executed from S510 in this embodiment. The only difference is that the second verification rule is used at this time, and the second value is verified.

[0163] That is to say, in this embodiment, no matter what form of nesting is used, the verification rule corresponding to the value to be verified is recursively obtained, and the current value is verified according to the verification rule to obtain the verification result.

[0164] For example, the above Figure 8 In the 4-layer nesting of the example, it is currently determined that the second keyword corresponds to the second verification rule, so the above process is repeated, that is, whether the second value is empty, as well as the subsequent process, and it is determined that the nesting type of the second value is a key-value pair, then it can be determined whether the third keyword in the third key-value pair corresponds to the third verification rule, and the above process is recursively executed until the verification result for the fourth value 233 is finally determined.

[0165] S511: Discard the first key-value pair or ignore the first key-value pair.

[0166] In another possible implementation, if it is determined that there is no corresponding second verification rule for the second keyword, the second key-value pair cannot be verified. The second key-value pair cannot be verified, which means that the first value cannot be verified. Therefore, the current first key-value pair is discarded, or the first key-value pair is ignored, and the next key-value pair is processed.

[0167] S512: Determine whether the data type of the first value is a string. If so, execute S513; if not, execute S514.

[0168] If it is determined that the data type of the first value is not a nested type, it indicates that the data type of the first value is a number or a character. When the data type of the first value is a character, the length of the character can be judged to verify the first value. Therefore, this embodiment can determine whether the data type of the first value is a string.

[0169] S513: Determine whether the length of the first value is within a preset length range, if so, execute S514, if not, execute S504.

[0170] If it is determined that the data type of the first value is a string, it can be determined whether the length of the first value is within a preset length range, where the preset length range can be information included in the first verification rule. If the length of the first value exceeds the preset length range, it can be determined that the verification has failed.

[0171] In another possible implementation, when the type of the first value is a list, it can also be determined whether the length of the first value is within a preset length range. If the length of the first value exceeds the preset length range, it can be determined that the verification has failed.

[0172] Because strings and lists can have corresponding lengths, this embodiment can perform a check based on the length of the first value when the first value is a string or a list. If a possible data type also has a corresponding length, the first value of the data type can also be checked based on the length.

[0173] S514: Get the check function.

[0174] In this embodiment, a check function may also be provided in the check table, wherein the check function is a type of server-side program used to check whether the data is legal, and may be written by a technician.

[0175] When the data type of the first value is a string and the length is within a preset length range, or when the first value is not a string, this embodiment may verify the first value according to the check function.

[0176] Among them, the type of the first value is a character type and the length of the first value is within a preset length range, which can indicate that the form of the first value is qualified. At this time, checking according to the check function can effectively save workload.

[0177] Also, when the type of the first value is not a string, because it has been determined that the first value is not a nested type, it can be determined that the type of the first value is a number. At this time, the first value has completed the verification that it is not empty and the data type is qualified. Therefore, the first value can be further tested as needed according to the check function to improve the accuracy of the test.

[0178] Therefore, the check function can be obtained. In a possible implementation method, only the function name of the check function can be stored in the check table. The engine will find the check function according to the function name to perform data verification. For example, according to the first keyword, the function name of the check function corresponding to the first keyword is obtained in the check table, so that the check function can be obtained according to the function name.

[0179] Alternatively, you can also use a lambda expression to implement the check function and store it in string form, which is dynamically loaded by the engine for data verification.

[0180] S515. Check whether the first value is legal by checking the function. If so, execute S503; if not, execute S504.

[0181] For example, the content of the data field of the first value can be checked according to the check concave function to determine whether the first value is legal. For example, when the check of the check function passes, the first value is determined to be legal, and the check result is determined to be a successful check; or when the check of the check function fails, the first value is determined to be illegal, and the check result is determined to be an unsuccessful check.

[0182] In the actual implementation process, the specific inspection logic of the inspection function can be selected according to actual needs, and this embodiment does not limit this.

[0183] The data processing method provided in the embodiment of the present application implements the verification of key-value pairs of nested types and non-nested types by means of a check table, which can effectively improve the efficiency of data verification, enhance the portability and reusability of the development process and the testing process, so that data verification does not need to be restricted by the data structure, and before performing differentiated processing on nested types and non-nested types, some common checks are performed first, thereby effectively improving the speed of data verification and reducing unnecessary verification steps. At the same time, a check function can also be written in this embodiment to realize dynamic verification of data and improve the accuracy of the verification results.

[0184] Fig. 9 This is a schematic diagram of the structure of the data processing device provided in the embodiment of the present application. Fig. 9 As shown, the device 90 includes: an acquisition module 901 and a verification module 902.

[0185] An acquisition module 901 is used to acquire a first verification rule corresponding to a first key-value pair, where the first key-value pair is any key-value pair in the data to be verified, and the first key-value pair includes a first keyword and a first value;

[0186] The acquisition module 901 is further used to acquire a data type of the first value, where the data type is a nested type or a non-nested type;

[0187] The verification module 902 is used to verify the first value according to the first verification rule and the data type to obtain a verification result.

[0188] In one possible design, the nested type includes at least one of the following types: a list, a key-value pair;

[0189] The non-nested type includes at least one of the following types: number, string.

[0190] In a possible design, the verification module 902 is specifically used for:

[0191] Determine whether the first value is empty;

[0192] If yes, if the first verification rule allows the value to be empty, then the verification result is determined to be a successful verification; if the first verification rule does not allow the value to be empty, then the verification result is determined to be a failed verification;

[0193] If not, determine whether the data type of the first value is one of the preset types in the first verification rule. If it is not one of the preset types, determine the verification result as verification failure. If it is one of the preset types, determine the verification result based on the data type of the first value.

[0194] In a possible design, the data type of the first value is a nested type;

[0195] The verification module 902 is specifically used for:

[0196] If the nested type is a list, the first value is the first list, and for each element in the first list, the above operation of determining whether the first value is empty is repeatedly performed to obtain a verification result for each element in the first list; or

[0197] If the nested type is a key-value pair, the first value is a second key-value pair, the second key-value pair includes a second keyword and a second value, and the second value is verified according to the second keyword and the check table corresponding to the data to be verified to obtain a verification result.

[0198] In a possible design, the verification module 902 is specifically used for:

[0199] Determine whether there is a second verification rule corresponding to the second keyword in the check table corresponding to the data to be verified;

[0200] If so, the second value is verified according to the second verification rule and the data type of the second value to obtain a verification result.

[0201] If not, the first key-value pair is discarded or ignored.

[0202] In a possible design, the data type of the first value is a non-nested type;

[0203] The verification module 902 is specifically used for:

[0204] Determine whether the data type of the first value is a string;

[0205] If so, when the length of the first value is not within a preset length range, the verification result is determined to be a verification failure.

[0206] If not, a check function is obtained, and the data type is checked by the check function to obtain the check result.

[0207] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.

[0208] Fig.10 A schematic diagram of the hardware structure of a data processing device provided in an embodiment of the present application is shown in FIG. Fig.10 As shown, the data processing device 100 of this embodiment includes: a processor 1001 and a memory 1002;

[0209] Memory 1002, used for storing computer-executable instructions;

[0210] The processor 1001 is used to execute the computer-executable instructions stored in the memory to implement the various steps performed by the data processing method in the above embodiment. For details, please refer to the relevant description in the above method embodiment.

[0211] Optionally, the memory 1002 may be independent or integrated with the processor 1001 .

[0212] When the memory 1002 is independently provided, the data processing device further includes a bus 1003 for connecting the memory 1002 and the processor 1001 .

[0213] An embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the data processing method executed by the above data processing device is implemented.

[0214] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0215] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present application.

[0216] It should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented by a hardware processor or implemented by a combination of hardware and software modules in the processor.

[0217] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.

[0218] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0219] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.

[0220] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0221] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A data processing method, characterized in that: include: Obtain a first verification rule corresponding to a first key-value pair, where the first key-value pair is any key-value pair in the data to be verified, and the first key-value pair includes a first keyword and a first value; Obtaining a data type of the first value, the data type being a nested type or a non-nested type; wherein the nested type includes at least one of the following types: a list, a key-value pair; the key-value pair being a key-value pair of N levels, the value of the key-value pair of the first level being the key-value pair of the second level, the value of the key-value pair of the second level being the key-value pair of the third level, and so on until the value of the key-value pair of the N-1 level is the key-value pair of the N level, wherein N is an integer greater than 1; Verify the first value for both the nested type and the non-nested type to determine whether the first value is empty; If yes, if the first verification rule allows the value to be empty, then the verification result is determined to be a successful verification; if the first verification rule does not allow the value to be empty, then the verification result is determined to be a failed verification; If not, determine whether the data type of the first value is one of the preset types corresponding to the first key in the first verification rule; if it is not one of the preset types corresponding to the first key, determine that the verification result is a verification failure; if it is one of the preset types corresponding to the first key, determine whether the data type of the first value is a nested type; if so, if the nested type is a list, the first value is a first list, and for each element in the first list, repeat the above operation of determining whether the first value is empty to obtain the verification result of each element in the first list; or If the nested type is a key-value pair, the first value is the second key-value pair, the second key-value pair includes a second keyword and a second value, and the second value is checked according to the check table corresponding to the second keyword and the data to be checked to determine whether the second value is empty. If not, the value of the key-value pair of the N-1th layer is the key-value pair of the Nth layer, and an operation of determining whether the Nth value is empty is performed. If not, the Nth verification rule corresponding to the Nth keyword in the Nth key-value pair is obtained to obtain the verification result of the Nth value.

2. The method according to claim 1, characterized in that The nested type includes at least one of the following types: a list, a key-value pair; The non-nested type includes at least one of the following types: number, string.

3. The method according to claim 1, characterized in that The step of verifying the second value according to the second keyword and the check table corresponding to the data to be verified to obtain a verification result includes: Determine whether there is a second verification rule corresponding to the second keyword in the check table corresponding to the data to be verified; If yes, verify the second value according to the second verification rule and the data type of the second value to obtain a verification result; If not, the first key-value pair is discarded or ignored.

4. The method according to claim 1 or 2, characterized in that: The data type of the first value is a non-nested type; and determining the verification result according to the data type of the first value includes: Determine whether the data type of the first value is a string; If yes, then when the length of the first value is not within a preset length range, determining that the verification result is a verification failure; If not, a check function is obtained, and the data type is checked by the check function to obtain the check result.

5. A data processing device, characterized in that: include: An acquisition module, configured to acquire a first verification rule corresponding to a first key-value pair, wherein the first key-value pair is any key-value pair in the data to be verified, and the first key-value pair includes a first keyword and a first value; The acquisition module is further used to acquire a data type of the first value, the data type being a nested type or a non-nested type; wherein the nested type includes at least one of the following types: a list, a key-value pair; the key-value pair is a key-value pair of N levels, the value of the key-value pair of the first level is the key-value pair of the second level, the value of the key-value pair of the second level is the key-value pair of the third level, and so on until the value of the key-value pair of the N-1 level is the key-value pair of the N level, where N is an integer greater than 1; A verification module, configured to verify the first value according to the first verification rule and the data type to obtain a verification result; The verification module is specifically used for: Verify the first value for both the nested type and the non-nested type to determine whether the first value is empty; If yes, if the first verification rule allows the value to be empty, then the verification result is determined to be a successful verification; if the first verification rule does not allow the value to be empty, then the verification result is determined to be a failed verification; If not, determine whether the data type of the first value is one of the preset types corresponding to the first key in the first verification rule; if it is not one of the preset types corresponding to the first key, determine that the verification result is a verification failure; if it is one of the preset types corresponding to the first key, determine whether the data type of the first value is a nested type; if so, if the nested type is a list, the first value is a first list, and for each element in the first list, repeat the above operation of determining whether the first value is empty to obtain the verification result of each element in the first list; or If the nested type is a key-value pair, the first value is the second key-value pair, the second key-value pair includes a second keyword and a second value, and the second value is checked according to the check table corresponding to the second keyword and the data to be checked to determine whether the second value is empty. If not, the value of the key-value pair of the N-1th layer is the key-value pair of the Nth layer, and an operation of determining whether the Nth value is empty is performed. If not, the Nth verification rule corresponding to the Nth keyword in the Nth key-value pair is obtained to obtain the verification result of the Nth value.

6. The device according to claim 5, characterized in that The nested type includes at least one of the following types: a list, a key-value pair; The non-nested type includes at least one of the following types: number, string.

7. The device according to claim 5, characterized in that The verification module is specifically used for: Determine whether there is a second verification rule corresponding to the second keyword in the check table corresponding to the data to be verified; If yes, verify the second value according to the second verification rule and the data type of the second value to obtain a verification result; If not, the first key-value pair is discarded or ignored.

8. The device according to claim 5 or 6, characterized in that The data type of the first value is a non-nested type; The verification module is specifically used for: Determine whether the data type of the first value is a string; If yes, then when the length of the first value is not within a preset length range, determining that the verification result is a verification failure; If not, a check function is obtained, and the data type is checked by the check function to obtain the check result.

9. A data processing device, characterized in that: include: Memory, used to store programs; A processor, configured to execute the program stored in the memory; when the program is executed, the processor is configured to execute the method according to any one of claims 1 to 4.

10. A computer-readable storage medium, characterized in that: The method comprises instructions which, when executed on a computer, cause the computer to perform the method as claimed in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method and device for outputting information

    CN109614327A