A data processing method and device
By converting the data into a preset data structure before the front-end acquires data, the problems of difficulty and high development cost of fault-tolerant processing of the front-end when processing massive data in the prior art are solved, and higher user experience and front-end stability are achieved.
Patent Information
- Application Number
- CN202111003656.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-30
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2041-08-30
AI Technical Summary
Against the backdrop of increasingly complex data structures, the difficulty of fault-tolerant processing and the amount of rendered data when processing massive data is increasing, resulting in increased development costs, easy front-end crashes, and poor user experience.
By converting the data into a preset data structure before the front-end acquires data, the data structure processing logic is extracted from the front-end, so that the front-end focuses on business development without paying attention to data structure exceptions and fault-tolerant processing.
It reduces the development cost of the front-end, prevents frequent abnormal error reports, improves user experience, and improves the stability of the front-end.
Smart Images

Figure CN113641359B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data processing method and device. Background Art
[0002] When the front end is processing data objects, if the acquired data is abnormal, it is usually necessary to perform fault-tolerant processing on the data so that the front end can respond to users normally.
[0003] When performing fault-tolerant processing on data, existing front-ends usually configure a fallback solution in advance so that when the data is abnormal, the front-end will render and display the erroneous data through the fallback solution. For example, when erroneous data appears on the page, feedback information is displayed to avoid white screen, no response, etc.
[0004] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0005] As data structures become increasingly complex, existing front-ends need to process massive amounts of data. The difficulty of fault-tolerant processing and the amount of data to be rendered are increasing, making the development cost of the front-end higher and higher. Moreover, if all abnormal data cannot be responded to in a timely manner, it is very easy to cause the front-end to crash, resulting in a poor user experience. Summary of the invention
[0006] In view of this, an embodiment of the present invention provides a data processing method and device, which can convert data into a preset data structure before the front end obtains the data, and extract the data structure processing logic from the front end, so that the front end can focus on its own business development without paying attention to data structure anomalies and fault-tolerant processing of massive data, thereby reducing the development cost of the front end, preventing frequent abnormal error reports, improving user experience, and improving the stability of the front end.
[0007] To achieve the above object, according to one aspect of an embodiment of the present invention, a data processing method is provided, comprising:
[0008] Receive the data to be processed returned by the backend;
[0009] Determine first data and / or second data from the data to be processed according to a preset data structure corresponding to the front end; wherein the first data is data matching the data structure, and the second data is data not matching the data structure;
[0010] In the case where the second data exists in the data to be processed: converting the second data into target data matching the data structure;
[0011] The first data and / or target data are sent to the front end, so that the front end renders the page according to the first data and / or target data.
[0012] Optionally, converting the second data into target data matching the data structure includes:
[0013] determining whether data content of the second data is abnormal;
[0014] When the data content of the second data is abnormal, reporting the abnormal data to the backend so that the backend corrects the abnormal data;
[0015] Receiving the corrected abnormal data sent by the back end;
[0016] The corrected abnormal data is converted into target data matching the data structure.
[0017] Optionally, when the number of consecutive reports of the abnormal data is greater than a preset number threshold, preset benchmark data is used as the target data, so that the front end renders a prompt page according to the benchmark data.
[0018] Optionally, when the data content of the second data is normal, the second data is converted into target data matching the data structure.
[0019] Optionally, the determining the first data and / or the second data from the first data to be processed according to a preset data structure corresponding to the front end includes:
[0020] Based on the data type, data value and / or data value range, and / or existence attribute corresponding to the data to be processed, check whether the data to be processed matches the data structure to determine the first data and / or the second data from the data to be processed.
[0021] Optionally, the data structure is in Json data format.
[0022] Optionally, the abnormal data includes any one or more of the following: the hierarchical structure of the data to be processed, data fields, interface names, and the IP, browser information, and operating system information corresponding to the front end.
[0023] According to another aspect of an embodiment of the present invention, there is provided a data processing device, including:
[0024] The receiving module is used to receive the data to be processed returned by the backend;
[0025] A judgment module, used to determine the first data and / or the second data from the data to be processed according to a preset data structure corresponding to the front end; wherein the first data is data that matches the data structure, and the second data is data that does not match the data structure;
[0026] A data processing module, configured to: convert the second data into target data matching the data structure if the second data exists in the data to be processed;
[0027] A sending module is used to send the first data and / or target data to the front end, so that the front end renders the page according to the first data and / or target data.
[0028] According to another aspect of an embodiment of the present invention, there is provided a data processing electronic device, comprising:
[0029] one or more processors;
[0030] a storage device for storing one or more programs,
[0031] When the one or more programs are executed by the one or more processors, the one or more processors implement the data processing method provided by the present invention.
[0032] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the data processing method provided by the present invention is implemented.
[0033] An embodiment of the above invention has the following advantages or beneficial effects: because a data structure written according to JSON Schema rules is adopted, the data to be processed returned by the back-end interface is converted into target data that conforms to a preset Json data format, so that the front-end renders the page according to the target data that conforms to the expected value; and, in the case where abnormal data exists in the data content, the abnormal data is reported to the back-end, and after receiving the corrected abnormal data, the data is returned to the front-end, so that the front-end renders the page according to the corrected abnormal data. The technical means overcomes the increasing cost of existing front-end development, which is extremely easy to cause the front-end to crash and result in poor user experience, and thus achieves the ability to convert data into a preset data structure before the front-end obtains the data, and extract the data structure processing logic from the front-end, so that the front-end can focus on its own business development without paying attention to data structure anomalies and fault-tolerant processing of massive data, thereby reducing the development cost of the front-end, preventing frequent abnormal error reporting, improving user experience, and improving the technical effect of the stability of the front-end.
[0034] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0036] Figure 1 is a schematic diagram of the main flow of a data processing method according to an embodiment of the present invention;
[0037] Figure 2 is a schematic diagram of the main process of the method for agreeing on a data format according to an embodiment of the present invention;
[0038] Figure 3 is a schematic diagram of the main process of the method for reporting abnormal data according to an embodiment of the present invention;
[0039] Figure 4 is a schematic diagram of main modules of a data processing device according to an embodiment of the present invention;
[0040] Figure 5 An exemplary system architecture diagram of a data processing method or a data processing device suitable for application in an embodiment of the present invention is shown;
[0041] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0042] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0043] Json Schema: Json mode refers to a custom or agreed Json data format, including members, structures, types, constraints, etc., which can be used to verify the Json data format; the Json Schema in the present invention is the Json data format agreed upon by the backend and the frontend. Since JSON Schema itself is in JSON format and is only used to describe another JSON data, it can be used as an execution code verification and as a code document for front-end and back-end development.
[0044] Figure 1 is a schematic diagram of the main flow of the data processing method according to an embodiment of the present invention, such as Figure 1As shown, the data processing method of the present invention includes:
[0045] Step S101, receiving the data to be processed returned by the backend.
[0046] In the embodiment of the present invention, the data to be processed returned by the back end is received through the intermediate server, the data to be processed is processed, and the processed data is returned to the front end.
[0047] Step S102, determining first data and / or second data from the data to be processed according to a preset data structure corresponding to the front end; wherein the first data is data matching the data structure, and the second data is data not matching the data structure.
[0048] In an embodiment of the present invention, based on the data type, data value and / or data value range, and / or existence attribute corresponding to the data to be processed, it is verified whether the data to be processed matches the data structure to determine the first data and / or second data from the data to be processed.
[0049] In the embodiment of the present invention, the data to be processed may be multi-level data. When verifying the data to be processed, the multi-level data to be processed needs to be verified level by level.
[0050] In the embodiment of the present invention, the data structure is in Json data format. The preset data structure corresponding to the front end can be a Json Schema rule pre-agreed between the back end and the front end. Specifically, when the front end and the back end communicate via data in Json data format, the rules of the data structure are determined according to the agreement of JSON Schema, including data type, value range, default value, whether required, description, title, etc.
[0051] In the embodiment of the present invention, Figure 2 As shown, the data format agreement method of the present invention includes the following steps:
[0052] Step S201, the backend creates an API interface corresponding to the frontend.
[0053] In the embodiment of the present invention, in order to transmit data according to the agreed data format, the back end is responsible for creating an API interface corresponding to one or more front ends for transmitting data to the front end.
[0054] Step S202: The backend or frontend writes JSON Schema rules.
[0055] In the embodiment of the present invention, developers of the backend or frontend write JSON Schema rules so that the backend and the frontend transmit data according to the agreed JSON data format.
[0056] In an embodiment of the present invention, the JSON Schema rule may be:
[0057]
[0058] Accordingly, the required object data is:
[0059]
[0060]
[0061] Among them, the data type of "name" is "string", that is, character string; the data type of "price" is "number", that is, number; the data type of "children" is "array", that is, array; the data value range of "price" includes: the minimum value is 0; "name", "price", and "children" are all required fields, corresponding to the existence attributes of the data format.
[0062] Step S203, determine the JSON data format.
[0063] In the embodiment of the present invention, the backend or the frontend determines the JSON data format according to the JSON Schema rules.
[0064] Step S204: output JSON Schema.
[0065] In an embodiment of the present invention, the backend or frontend responsible for writing JSON Schema rules outputs JSON Schema, for example, outputs JSON Schema in the form of an interface or document, so that developers of the backend or frontend can update it according to specific usage scenarios, or correct abnormal data, etc.
[0066] Furthermore, if you need to adjust the API interface, you can rewrite the JSON Schema rules.
[0067] In the embodiment of the present invention, through the data format agreement method of the present invention, the data format of the front-end and back-end interaction can be clearly described, and it is clear that the expected data of the front-end and back-end interaction should comply with the agreed JSON Schema rules, so that the back-end outputs data according to the agreed data format and the front-end receives data in the data format agreed upon by both parties.
[0068] In the embodiment of the present invention, for example, the data to be processed received by the intermediate server and returned by the backend is:
[0069]
[0070] Among them, according to the data type "string" corresponding to "name", David is checked, and it is determined that the data type of David is "string", which matches the data structure, and "name":David is the first data; according to the data type "number" corresponding to "price", null is checked, and it is determined that the data type of null is not "number", which does not match the data structure, and "price":null is the second data; "children" is a required field, and the data corresponding to the "children" field does not exist in the data to be processed, and the existence attribute of "children" is abnormal.
[0071] Step S103, when the second data exists in the data to be processed: convert the second data into target data matching the data structure.
[0072] In the embodiment of the present invention, the second data is data that does not match the data structure. When the intermediate server determines that the second data exists in the data to be processed, it converts the second data into target data that matches the data structure. However, in the process of converting the second data, there may be situations where the data cannot be converted or there are abnormal data that does not conform to the preset data structure after conversion. Therefore, the data content corresponding to such abnormal data needs to be reported to the back end so that the developers of the back end can correct the abnormal data so that the corrected data content conforms to the preset data structure.
[0073] In the embodiment of the present invention, Figure 3 As shown, the method for reporting abnormal data of the present invention includes the following steps:
[0074] Step S301, determine whether the data content of the second data is abnormal; if yes, go to step S302; if no, go to step S310.
[0075] In the embodiment of the present invention, the intermediate server will automatically check whether the data content of the second data meets the expected value. For example, the intermediate server receives the data to be processed returned by the back end as:
[0076]
[0077] Among them, the data content corresponding to "price" is null and abnormal; the data corresponding to the "children" field is missing, and the data content of "children" is abnormal.
[0078] Step S302, determining abnormal data.
[0079] Step S303, determine whether the number of consecutive reports of abnormal data is greater than a preset number threshold, if yes, go to step S304; if not, go to step S305.
[0080] Step S304, when the number of consecutive reports of abnormal data is greater than a preset number threshold, the preset benchmark data is used as the target data, so that the front end renders a prompt page according to the benchmark data.
[0081] In an embodiment of the present invention, the front end performs fault-tolerant processing on the abnormal data. The fault-tolerant processing refers to displaying the abnormal data through a fallback solution. For example, the front-end page renders the object name obj.name, and the received abnormal data is "undefined". If it is rendered directly according to "undefined", the front-end page may be abnormal, resulting in a poor user experience; the front end can process "undefined" into {}, and then process obj.name into "", that is, an empty string. The empty string is the corresponding fallback solution, so that the front end renders the page according to the empty string to prevent the occurrence of abnormal error reporting. Alternatively, the front end can render the abnormal data as an error prompt page (for example, "error", or × picture, etc.).
[0082] In an embodiment of the present invention, benchmark data can also be preset. When the number of consecutive reports of abnormal data exceeds a preset threshold, the abnormal data is corrected to benchmark data, and the benchmark data is sent to the front end as target data, so that the front end renders a prompt page according to the benchmark data; wherein the benchmark data is a fallback data, for example, "".
[0083] Step S305, reporting the abnormal data to the backend so that the backend corrects the abnormal data.
[0084] In an embodiment of the present invention, the abnormal data may be a hierarchical structure of the data to be processed, a data field, a value corresponding to the data field, an interface name, and an IP, browser information, or operating system information corresponding to the front end. The abnormal data may be sent to the back end in the form of a message, so that the back end parses the message and determines the abnormal data. The reporting service and parameter format of the abnormal data are not restricted here, and the determination can be made according to the parsing method of the data by the back end of the reporting system.
[0085] For example, the backend corrects the data content corresponding to "price" to "10" and adds the "children" field and its corresponding data content.
[0086] In the embodiment of the present invention, abnormal data may be reported by calling a reporting callback function.
[0087] Step S306, incrementing the number of abnormal data reporting times.
[0088] Step S307, receiving the corrected abnormal data sent by the back end.
[0089] In the embodiment of the present invention, when the data content of the corrected abnormal data is normal, the corrected abnormal data is used as the target data, and the target data is sent to the front end.
[0090] Step S308, determine whether the data content of the corrected abnormal data is abnormal; if yes, go to step S302; if no, go to step S309.
[0091] Step S309: converting the corrected abnormal data into target data matching the data structure.
[0092] In an embodiment of the present invention, the target data is sent to the front end so that the front end renders the page according to the corrected abnormal data that matches the data structure.
[0093] Step S310: convert the second data into target data matching the data structure.
[0094] In the embodiment of the present invention, when the data content of the second data is normal, the second data is used as target data, and the target data is sent to the front end, so that the front end renders the page according to the second data matching the data structure.
[0095] In an embodiment of the present invention, through the reporting method of abnormal data of the present invention, on the one hand, the backend can determine the abnormal data according to the reported information, helping developers to quickly locate data problems, including but not limited to API addresses, request parameters, front-end information, etc.; on the other hand, when reporting abnormal data, no error will be reported on the front-end page, so that users are unaware of the abnormal data and the user experience is improved; on the other hand, the front-end only needs to render, develop, etc. according to data that conforms to the preset data structure, without the need to perform data structure judgment, so that the front-end developers do not need to pay excessive attention to the data structure, and can focus on the development of business logic, improve development efficiency, and reduce the situation of program abnormality errors.
[0096] In the embodiment of the present invention, the intermediate server may pre-configure the reporting service (eg, reporting callback function) and the agreed data structure, and encapsulate the reporting service and the agreed data structure into one component.
[0097] Furthermore, the intermediate server can choose to turn on or off the reporting service, and choose to report or not report the abnormal data. When not reporting the abnormal data, the abnormal data can be sent to the front end as target data, so that the front end renders the prompt page according to the abnormal data; or, the abnormal data can be corrected into benchmark data, and the benchmark data can be sent to the front end as target data, so that the front end renders the page according to the benchmark data.
[0098] In an embodiment of the present invention, the intermediate server can convert the second data by introducing a conversion module, and report the abnormal data that does not meet the expected value. For example, the conversion module is data=convert(data,schema), which converts data according to Json schema and reports the abnormal data in data that does not meet the expected value.
[0099] Step S104: sending the first data and / or target data to the front end, so that the front end renders the page according to the first data and / or target data.
[0100] In an embodiment of the present invention, by receiving the data to be processed returned by the backend; determining the first data and / or the second data from the data to be processed according to a preset data structure corresponding to the front end; wherein the first data is data matching the data structure, and the second data is data not matching the data structure; in the case where the second data exists in the data to be processed: converting the second data into target data matching the data structure; sending the first data and / or the target data to the front end, so that the front end renders the page according to the first data and / or the target data, etc., before the front end obtains the data, the data can be converted into a preset data structure, and the data structure processing logic can be extracted from the front end, so that the front end can focus on its own business development without paying attention to data structure anomalies and fault-tolerant processing of massive data, thereby reducing the development cost of the front end, preventing frequent abnormal error reporting, improving user experience, and improving the stability of the front end.
[0101] Figure 4 is a schematic diagram of main modules of a data processing device according to an embodiment of the present invention, such as Figure 4 As shown, the data processing device 400 of the present invention includes:
[0102] The receiving module 401 is used to receive the data to be processed returned by the back end.
[0103] In the embodiment of the present invention, the receiving module 401 of the intermediate server receives the data to be processed returned by the back end, processes the data to be processed, and returns the processed data to the front end.
[0104] The judgment module 402 is used to determine the first data and / or the second data from the data to be processed according to a preset data structure corresponding to the front end; wherein the first data is data that matches the data structure, and the second data is data that does not match the data structure.
[0105] In an embodiment of the present invention, based on the data type, data value and / or data value range, and / or existence attribute corresponding to the data to be processed, the judgment module 402 verifies whether the data to be processed matches the data structure to determine the first data and / or the second data from the data to be processed.
[0106] In the embodiment of the present invention, the data to be processed may be multi-level data. When verifying the data to be processed, the multi-level data to be processed needs to be verified level by level.
[0107] In the embodiment of the present invention, the data structure is in Json data format. The preset data structure corresponding to the front end can be a Json Schema rule pre-agreed between the back end and the front end. Specifically, when the front end and the back end communicate via data in Json data format, the rules of the data structure are determined according to the agreement of JSON Schema, including data type, value range, default value, whether required, description, title, etc.
[0108] The data processing module 403 is used for converting the second data into target data matching the data structure when the second data exists in the data to be processed.
[0109] In the embodiment of the present invention, the second data is data that does not match the data structure. When determining that the second data exists in the data to be processed, the data processing module 403 of the intermediate server converts the second data into target data that matches the data structure. However, in the process of converting the second data, there may be situations where the data cannot be converted or there are abnormal data that does not conform to the preset data structure after conversion. Therefore, the data content corresponding to such abnormal data needs to be reported to the back end so that the developers of the back end can correct the abnormal data so that the corrected data content conforms to the preset data structure.
[0110] The sending module 404 is used to send the first data and / or target data to the front end, so that the front end renders the page according to the first data and / or target data.
[0111] In an embodiment of the present invention, through modules such as a receiving module, a judgment module, a data processing module and a sending module, data can be converted into a preset data structure before the front end obtains the data, and the data structure processing logic can be extracted from the front end, so that the front end can focus on its own business development without paying attention to data structure anomalies and fault-tolerant processing of massive data, thereby reducing the development cost of the front end, preventing frequent abnormal error reports, improving user experience, and improving the stability of the front end.
[0112] Figure 5 An exemplary system architecture diagram of a data processing method or a data processing device suitable for application in an embodiment of the present invention is shown. Figure 5 As shown, an exemplary system architecture of the data processing method or data processing device according to an embodiment of the present invention includes:
[0113] like Figure 5 As shown, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, an intermediate server 505, and a server 506. The network 504 is used to provide a medium for communication links between the terminal devices 501, 502, 503 and the intermediate server 505, and between the intermediate server 505 and the server 506. The network 504 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0114] Users can use terminal devices 501, 502, 503 to interact with server 506 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0115] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0116] The server 506 may be a server that provides various services, such as a background management server that provides support for web browser-type websites browsed by users using the terminal devices 501, 502, and 503. The background management server may analyze and process the received data query requests, etc., and feed back the processing results (such as data to be processed) to the intermediate server 505.
[0117] The intermediate server 505 may be a server that provides data processing, such as a background management server that provides support for data format conversion of the data to be processed returned by the server 506. The background management server may analyze and process the received data format conversion request, and feed back the processing result (such as target data that conforms to a preset data format) to the terminal devices 501, 502, and 503.
[0118] It should be noted that the data processing method provided in the embodiment of the present invention is generally executed by the intermediate server 505 , and accordingly, the data processing device is generally arranged in the intermediate server 505 .
[0119] It should be understood that Figure 5 The number of terminal devices, networks, intermediate servers and servers in the embodiment is only for illustration. Any number of terminal devices, networks, intermediate servers and servers may be provided according to implementation requirements.
[0120] Figure 6 is a schematic diagram of a computer system of a terminal device or server suitable for implementing an embodiment of the present invention, such as Figure 6 As shown, the computer system 600 of the terminal device or server of the embodiment of the present invention includes:
[0121] A central processing unit (CPU) 601 can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage section 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the system 600 are also stored in the RAM 603. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0122] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0123] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0124] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0125] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0126] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a receiving module, a judgment module, a data processing module and a sending module. The names of these modules do not constitute a limitation on the modules themselves in some cases, for example, the data processing module may also be described as "a module for converting the second data into target data matching the data structure".
[0127] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: receiving the data to be processed returned by the backend; determining the first data and / or the second data from the data to be processed according to the preset data structure corresponding to the front end; wherein the first data is data matching the data structure, and the second data is data not matching the data structure; when the second data exists in the data to be processed: converting the second data into target data matching the data structure; sending the first data and / or the target data to the front end, so that the front end renders the page according to the first data and / or the target data.
[0128] Existing front-ends usually process object data in a data fault-tolerant manner. When the data level of the object data returned by a certain interface during the interaction between the front-end and the back-end is too deep (for example, more than three levels), the front-end needs to continuously perform fault-tolerant processing on the data. However, as the frequency of front-end technology updates and iterations continues to increase, the page interaction between the front-end and the back-end becomes more complicated. Faced with object data with too deep a level, the data complexity becomes increasingly high. The front-end faces great challenges in processing page rendering data and performing fault-tolerant processing. Fault-tolerant processing is required every time data is obtained or modified, which makes the development cost of the front-end increasingly high, and it is extremely easy to lose control of the data, resulting in unpredictable errors.
[0129] According to the technical solution of the embodiment of the present invention, through the data structure written according to the JSON Schema rules, the data to be processed returned by the back-end interface is automatically converted into target data that meets the expected data structure. The front-end does not need to continuously perform fault-tolerant processing in the process of obtaining or modifying data, thereby reducing the development cost of the front-end. At the same time, abnormal data that does not meet the expected values is reported and processed, and the problem data can be quickly located and corrected, so that users are not aware of the abnormal data, which greatly improves the user experience.
[0130] According to the technical solution of the embodiment of the present invention, before the front end obtains the data, the data is converted into a preset data structure, and the data structure processing logic is extracted from the front end, so that the front end can focus on its own business development without having to pay attention to data structure anomalies and perform fault-tolerant processing on massive data. This reduces the development cost of the front end, prevents frequent abnormal error reports, improves user experience, and improves the stability of the front end.
[0131] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data processing method, characterized in that: include: Receive the data to be processed returned by the backend; Determine first data and / or second data from the data to be processed according to a preset data structure corresponding to the front end; wherein the first data is data matching the data structure, and the second data is data not matching the data structure; In the case where the second data exists in the data to be processed: converting the second data into target data matching the data structure; Sending the first data and / or target data to the front end, so that the front end renders the page according to the first data and / or target data; The converting the second data into target data matching the data structure comprises: determining whether data content of the second data is abnormal; When the data content of the second data is abnormal, reporting the abnormal data to the backend so that the backend corrects the abnormal data; Receiving the corrected abnormal data sent by the back end; The corrected abnormal data is converted into target data matching the data structure.
2. The method according to claim 1, characterized in that: When the number of consecutive reports of the abnormal data is greater than a preset number threshold, the preset benchmark data is used as the target data, so that the front end renders a prompt page according to the benchmark data.
3. The method according to claim 1, characterized in that When the data content of the second data is normal, the second data is converted into target data matching the data structure.
4. The method according to claim 1, characterized in that: The step of determining the first data and / or the second data from the first data to be processed according to a preset data structure corresponding to the front end includes: Based on the data type, data value and / or data value range, and / or existence attribute corresponding to the data to be processed, check whether the data to be processed matches the data structure to determine the first data and / or the second data from the data to be processed.
5. The method according to any one of claims 1 to 4, characterized in that: The data structure is in Json data format.
6. The method according to claim 1 or 2, characterized in that: The abnormal data includes any one or more of the following: the hierarchical structure, data field, interface name of the data to be processed, and the IP, browser information, and operating system information corresponding to the front end.
7. A data processing device, characterized in that: include: The receiving module is used to receive the data to be processed returned by the backend; A judgment module, used to determine the first data and / or the second data from the data to be processed according to a preset data structure corresponding to the front end; wherein the first data is data that matches the data structure, and the second data is data that does not match the data structure; A data processing module, configured to: convert the second data into target data matching the data structure if the second data exists in the data to be processed; A sending module, used to send the first data and / or target data to the front end, so that the front end renders the page according to the first data and / or target data; The data processing module is also used for: determining whether data content of the second data is abnormal; When the data content of the second data is abnormal, reporting the abnormal data to the backend so that the backend corrects the abnormal data; Receiving the corrected abnormal data sent by the back end; The corrected abnormal data is converted into target data matching the data structure.
8. A data processing electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Page rendering method and device, electronic equipment and computer readable medium
CN111984888A