JSON-based data processing method, device, equipment and medium

Through the cooperation of preset selectors and custom adapters, incompatibility problems caused by JSON parser switching are solved, compatibility and efficient switching of different JSON parsing tool classes are achieved, and service request parsing failures and increases in code modifications are avoided. .

CN112433709BActive Publication Date: 2024-08-16WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011413471.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-03
Publication Date
2024-08-16
Estimated Expiration
2040-12-03

AI Technical Summary

Technical Problem

Existing technologies cause incompatibility issues when switching JSON parsers, requiring large-scale code modifications in distributed systems, and service request parsing failures may occur during grayscale publishing, resulting in service unavailability.

Method used

Determine the target JSON parsing tool class through a preset selector, and perform deserialization processing through a custom adapter to ensure compatibility between different JSON parsing tool classes and achieve switching at the code level with as little modification as possible.

Benefits of technology

It achieves compatibility between different JSON parsing tool classes, avoids service request parsing failures, reduces the amount of code modifications, and improves the switching efficiency of JSON parsing tool classes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112433709B
    Figure CN112433709B
Patent Text Reader

Abstract

The present invention relates to the technical field of financial technology (Fintech), and discloses a JSON-based data processing method, comprising: determining a target parsing tool class according to a preset selector when receiving a service request sent by a requester, wherein the preset selector includes at least one parsing tool class; the service request includes a first string obtained by the requester according to a first custom adapter; calling a corresponding second custom adapter through the target parsing tool class to deserialize the first string to obtain a first Java object, so as to process the service request according to the first Java object, and the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter. Therefore, when the JSON parsing tool classes of the requester and the responder are different, the responder can still successfully deserialize the first string through the adapter, thereby achieving compatibility of different JSON parsing tool classes of the requester and the responder.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of financial technology (Fintech), and in particular to a JSON-based data processing method, device, equipment and computer storage medium. Background Art

[0002] With the development of computer technology, more and more technologies (big data, distributed, artificial intelligence, etc.) are applied in the financial field. The traditional financial industry is gradually transforming to financial technology (Fintech). However, due to the security and versatility requirements of the financial industry, higher requirements are also placed on JSON-based data processing technology.

[0003] FastJson is an open source JSON parsing library of Alibaba. It is widely sought after by domestic developers for its fast parsing speed, wide use and complete functions. However, in the later use process, it is found that its source code quality is poor and it does not strictly follow the JSON standard. More importantly, security vulnerabilities have been exposed one after another, and developers are forced to face the process of frequently updating versions to fix vulnerabilities. In fact, its fast parsing speed is not significantly better than that of several other JSON parsing libraries, but developers have to endure the pain of insecure system for a long time, so the best solution is to abandon FastJson and replace it with the safer Gson or Jackson.

[0004] Most of the existing solutions for replacing JSON parsing are to directly modify the JsonUtil tool class and switch the underlying JSON components to Gson or Jackson in a one-size-fits-all manner. As a result, the traditional solution can only use one fixed JSON parser to parse the message on the machines in the distributed system. If the parser is to be switched for the distributed machines in the distributed system, large-scale modifications are required, or even the entire underlying code needs to be replaced, which is a large workload. Moreover, during the grayscale release process, this solution may result in message transmission between the old machine using the FastJson parser and the new machine using the Gson parser or the Jackson parser. Since the serialization and deserialization processes of the two JSON parsers are different, the two are incompatible, which will cause the service request parsing to fail, and ultimately lead to service unavailability. Summary of the invention

[0005] The main purpose of the present invention is to propose a JSON-based data processing method, device, equipment and computer storage medium, aiming to solve the technical problem of incompatibility caused by switching JSON parsers.

[0006] To achieve the above object, the present invention provides a JSON-based data processing method, which comprises the following steps:

[0007] When receiving a service request sent by a requester, determining a target JSON parsing tool class according to a preset selector, wherein the preset selector includes at least one JSON parsing tool class; the service request includes a first JSON string obtained by the requester according to a first custom adapter;

[0008] The first JSON string is deserialized by calling the corresponding second custom adapter through the target JSON parsing tool class to obtain a first Java object, so as to process the service request according to the first Java object, wherein the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter.

[0009] Optionally, before the step of determining the target JSON parsing tool class according to the preset selector, the method further includes:

[0010] The preset configuration file is read regularly by the timing polling thread in the preset selector, and the value of the pointer variable in the preset selector is determined according to the tool class identifier in the preset configuration file;

[0011] The step of determining the target JSON parsing tool class according to the preset selector includes:

[0012] The value of the pointer variable in the preset selector is obtained, and the target JSON parsing tool class is determined according to the value of the pointer variable.

[0013] Optionally, after the step of periodically reading a preset configuration file through the periodic polling thread in the preset selector, the method further includes:

[0014] If the preset configuration file is not read, the JSON parsing tool class used by the responder when processing the service request most recently is used as the target JSON parsing tool class.

[0015] Optionally, after the step of determining the value of the pointer variable in the preset selector according to the tool class identifier in the preset configuration file, the method further includes:

[0016] If it is determined according to the tool class identifier in the preset configuration file that the value of the pointer variable in the preset selector has changed, the change is recorded in the log.

[0017] Optionally, after the step of obtaining the first Java object to process the service request according to the first Java object, the method further includes:

[0018] Acquire a second Java object obtained by the responder processing the first Java object;

[0019] The second Java object is serialized by calling a second custom adapter through the target JSON parsing tool class to obtain a second JSON string, and the second string is fed back to the requesting party.

[0020] Optionally, before the step of determining the target JSON parsing tool class according to a preset selector when receiving the service request sent by the requester, the method further includes:

[0021] When the attribute configuration instruction is received, the attribute configuration content of the first custom adapter and the attribute configuration content of the second custom adapter are set according to the attribute configuration instruction, so that the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter.

[0022] Optionally, the JSON-based data processing method is applied to a distributed system, the distributed system includes the responder, and the JSON-based data processing method further includes:

[0023] receiving a first remote transmission script, and updating a preset configuration file of the responder according to the first remote transmission script;

[0024] A response operation is performed based on the updated preset configuration file, and the response result is recorded in a log, wherein when the response result is a successful response, the distributed system updates the preset configuration files of other responders in the distributed system; when the response result is an abnormal response, the responder receives a second remote transmission script, and rolls back the preset configuration file of the responder according to the second remote transmission script.

[0025] In addition, to achieve the above-mentioned purpose, the present invention further provides a JSON-based data processing device, the JSON-based data processing device comprising:

[0026] A determination module, configured to determine a target JSON parsing tool class according to a preset selector upon receiving a service request sent by a requester, wherein the preset selector includes at least one JSON parsing tool class; the service request includes a first JSON string obtained by the requester according to a first custom adapter;

[0027] A processing module is used to call the corresponding second custom adapter through the target JSON parsing tool class to deserialize the first JSON string to obtain a first Java object, so as to process the service request according to the first Java object, wherein the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter.

[0028] In addition, to achieve the above-mentioned purpose, the present invention also provides a JSON-based data processing device, which includes: a memory, a processor, and a JSON-based data processing program stored in the memory and executable on the processor, and the JSON-based data processing program, when executed by the processor, implements the steps of the JSON-based data processing method as described above.

[0029] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer storage medium, on which a JSON-based data processing program is stored, and when the JSON-based data processing program is executed by a processor, the steps of the JSON-based data processing method as described above are implemented.

[0030] The present invention determines the target JSON parsing tool class according to a preset selector when receiving a service request sent by a requester, wherein the preset selector includes at least one JSON parsing tool class; the service request includes a first JSON string obtained by the requester according to a first custom adapter; the target JSON parsing tool class calls the corresponding second custom adapter to deserialize the first JSON string to obtain a first Java object, so as to process the service request according to the first Java object, wherein the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter. Therefore, even if the JSON parsing tool classes of the requester and the responder are different, the responder can still successfully deserialize the first JSON string through the adapter, thereby achieving compatibility between different JSON parsing tool classes of the requester and the responder, and further achieving the solution of the incompatibility problem caused by switching JSON parsers under the premise of modifying the code layer as little as possible. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a schematic diagram of the structure of a data processing device based on JSON in a hardware operating environment involved in an embodiment of the present invention;

[0032] Figure 2 This is a flow chart of a first embodiment of a data processing method based on JSON according to the present invention;

[0033] Figure 3 It is a schematic diagram of the device modules of the JSON-based data processing device of the present invention.

[0034] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0035] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0036] like Figure 1 As shown, Figure 1 It is a schematic diagram of the structure of a JSON-based data processing device in a hardware operating environment involved in an embodiment of the present invention.

[0037] The JSON-based data processing device in the embodiment of the present invention may be a PC or a server device, on which a Java virtual machine runs.

[0038] like Figure 1 As shown, the JSON-based data processing device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0039] Those skilled in the art will understand that Figure 1 The JSON-based data processing device structure shown in the figure does not constitute a limitation of the device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0040] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a JSON-based data processing program.

[0041] exist Figure 1 In the JSON-based data processing device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the JSON-based data processing program stored in the memory 1005, and perform the operations in the following JSON-based data processing method.

[0042] Based on the above hardware structure, an embodiment of a data processing method based on JSON of the present invention is proposed.

[0043] JSON: It is a lightweight data exchange format that uses a text format that is completely independent of programming languages ​​to store and represent data. The simplicity and clear hierarchical structure make JSON an ideal data exchange language. It is easy to read and write, as well as easy to parse and generate, and effectively improves network transmission efficiency.

[0044] Reference Figure 2 , Figure 2 This is a flow chart of a first embodiment of a data processing method based on JSON according to the present invention, wherein the method comprises:

[0045] Step S10, upon receiving a service request sent by a requester, determining a target JSON parsing tool class according to a preset selector, wherein the preset selector includes at least one JSON parsing tool class; the service request includes a first JSON string obtained by the requester according to a first custom adapter;

[0046] The data transmission method of this embodiment is applied to a JSON-based data processing device, which may be a terminal, a robot or a PC device.

[0047] In the prior art, most solutions for replacing JSON parsing are to directly modify the JsonUtil tool class and switch the underlying JSON components to Gson or Jackson in a one-size-fits-all manner. As a result, the traditional solution can only use a fixed JSON parser to parse the message on the machines in the distributed system. If the parser is to be switched for the distributed machines in the distributed system, a large-scale modification is required, or even the entire underlying code is replaced, which is a large workload. Moreover, during the grayscale release process, this solution may cause message transmission between the old machine using the FastJson parser and the new machine using the Gson parser or the Jackson parser. Since the serialization and deserialization processes of the two JSON parsers are different, the two are incompatible, which will cause the service request parsing to fail, and ultimately lead to service unavailability.

[0048] In this context, when this embodiment receives a service request from the requester, it will determine the target JSON parsing tool class in the optional JSON parsing tool class according to the preset selector, and then deserialize the JSON string contained in the service request through the second adapter corresponding to the tool class. Since the JSON string is serialized by the requester through the first adapter, and the property configuration content of the first custom adapter is the same as the property configuration content of the second custom adapter, even if the JSON parsing tool class of the requester is different from that of the responder, the responder can still successfully deserialize the first JSON string through the adapter, thereby achieving compatibility between requesters and responders with different JSON parsing tool classes, and then solving the incompatibility problem caused by switching JSON parsers with as little modification as possible to the code layer.

[0049] It is important to understand that when two interacting parties are communicating remotely, they can send various types of data to each other, but no matter what type of data it is, it will be transmitted over the network in the form of a binary sequence.

[0050] In this embodiment, the sender needs to convert the Java object into a binary sequence (i.e., JSON string) through a JSON parser, and this process is called serialization, before it can be transmitted on the network; the receiver needs to restore the received binary sequence to an object through a JSON parser, and this process is called deserialization, before it can be processed.

[0051] Before step S10, for ease of use, this embodiment will package the JSON parser into a JSON parsing tool class, and then use the JSON parsing tool class to serialize Java objects and deserialize JSON strings. Different JSON parsers are packaged to obtain different JSON parsing tool classes. For example, the JSON parsing tool class obtained by packaging the FastJson parser is JsonUtil_FastJson, and the custom adapter of JsonUtil_FastJson is FastJsonAdapter; the JSON parsing tool class obtained by packaging the Gson parser is JsonUtil_Gson, and the custom adapter of JsonUtil_Gson is GsonAdapter; the JSON parsing tool class obtained by packaging the Jackson parser is JsonUtil_Jackson, and the custom adapter of JsonUtil_Jackson is JacksonAdapter.

[0052] In addition, a corresponding custom adapter will be set for the JSON parsing tool class during packaging. Developers can use the custom adapter to customize the data format of serialization and deserialization output, for example, custom processing of multiple data formats such as BigDecimal, BigInteger, Double, Long, etc., such as outputting two decimal places.

[0053] It is understandable that the JSON parser of the requester and responder in this embodiment can be any parser among FastJson, Gson and Jackson, of course, it can also be other JSON parsers, and this embodiment does not specifically limit the type of JSON parser. The JSON parsers of the requester and responder can be the same or different.

[0054] It should be noted that no matter which JSON parsing tool class is used, it contains several common serialization and deserialization methods, such as:

[0055] String formatWithPretty(Object o); Serialize object;

[0056] String formatArgs(Object[]args);Serialize array object;

[0057] String formatList(List <object>list); serialize list object;

[0058] String formatPkg(Map<String,Object> request); serialize communication messages;

[0059] <t>String formatEntity(T entity); serialize the object;

[0060] <t>String formatEntityWithClassName(T entity);Serialize the object;

[0061] Map<String,Object> parse(String s); deserialize map object;

[0062] Object[]parseArgs(String argsJsons); Deserialize array object;

[0063] <t>T parseEntity(String s,Type type); Deserialize the object, you can specify the object type type;

[0064] List <object>parseList(String s); Deserializes a list object.

[0065] The above are just examples of general methods, and do not constitute a limitation on general methods. Developers can set general methods as needed, and these general methods can also use existing general methods. It can be understood that the general method is actually a description of the serialization or deserialization results, but the specific execution is done by the target JSON parsing tool class determined by the selector. Each JSON parsing tool class can implement the above general methods, but the implementation process may be different.

[0066] Furthermore, before step S10, the method further includes:

[0067] Step a1, periodically reading a preset configuration file through a timed polling thread in the preset selector, and determining the value of a pointer variable in the preset selector according to a tool class identifier in the preset configuration file;

[0068] Correspondingly, the step of determining the target JSON parsing tool class according to the preset selector specifically includes:

[0069] Step a2, obtaining the value of the pointer variable in the preset selector, and determining the target JSON parsing tool class according to the value of the pointer variable.

[0070] In this embodiment, the preset selector is actually a JsonUtilFactory class, which contains a timed polling thread and a pointer variable. The timed polling thread can read the preset configuration file (json.properties) every N seconds, and set the value of the pointer variable according to the tool class identifier in the preset configuration file. Then, when receiving the service request sent by the requester, the selector can determine the target JSON parsing tool class according to the value of the pointer variable at the current moment. Among them, the preset configuration file is set by the developer as needed and uploaded to the responder. By setting the preset configuration file, the dynamic switching of the JSON parsing tool class can be realized.

[0071] For example, if gson is recognized in json.properties, the value of the pointer variable is set to point to JsonUtil_Gson. Correspondingly, if a service request is received at this time, the selector uses JsonUtil_Gson as the target JSON parsing tool class; if FastJson is recognized in json.properties, the value of the pointer variable is set to point to JsonUtil_FastJson. Correspondingly, if a service request is received at this time, the selector uses JsonUtil_FastJson as the target JSON parsing tool class; if Jackson is recognized in json.properties, the value of the pointer variable is set to point to JsonUtil_Jackson. Correspondingly, if a service request is received at this time, the selector uses JsonUtil_Jackson as the target JSON parsing tool class.

[0072] Through the above scheme, this embodiment can realize the dynamic setting of JSON parsing tool class without globally changing the code, and because there is no need to change the code globally, hot switching of JSON parsing tool class can be realized, thereby improving the switching efficiency of JSON parsing tool class.

[0073] Furthermore, if the developer has not uploaded the preset configuration file to the responder, it means that the developer has not specified the JSON parsing tool class at this time, and the scheduled polling thread will not be able to read the tool class identifier in the preset configuration file. Of course, other reading exceptions may also cause the scheduled polling thread to be unable to read the tool class identifier in the preset configuration file. At this time, you can continue to use the original JSON parsing tool class, that is, the JSON parsing tool class used by the responder when processing the service request most recently is used as the target JSON parsing tool class to avoid service exceptions caused by failure to read the tool class identifier in the preset configuration file.

[0074] Furthermore, after the above step a1, the method further includes:

[0075] If it is determined according to the tool class identifier in the preset configuration file that the value of the pointer variable in the preset selector has changed, the change is recorded in the log.

[0076] In this embodiment, after the value of the pointer variable is determined according to the tool class identifier read by the timing polling thread, the value of the pointer variable this time is compared with the value of the pointer variable determined according to the tool class identifier read by the timing polling thread last time to determine whether the two are the same. If they are the same, it means that the developer has not changed the JSON parsing tool class during this period; if they are different, it means that the developer has changed the tool class identifier in the preset configuration file during this period. In order to facilitate developers to check whether the switch of the JSON parsing tool class is successful, the change of the pointer can be recorded in the log. For example, Current JSON Parser switched to Gson / Gastjson / Jackson.

[0077] Step S20, calling the corresponding second custom adapter through the target JSON parsing tool class to deserialize the first JSON string to obtain a first Java object, so as to process the service request according to the first Java object, wherein the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter.

[0078] In this embodiment, whether it is the requester or the responder, when receiving external data as the receiver or sending data to the outside as the sender, it is necessary to convert the received data and the sent data through the custom adapter corresponding to its current JSON parsing tool class.

[0079] Specifically, before sending a service request to the responder, the requester will first serialize the Java object to be processed through the requester's JSON parsing tool class and the first custom adapter, and the data format of the first JSON string obtained by serialization is determined according to the property configuration content in the first custom adapter. Then, the requester sends a service request containing the first JSON string to the responder. After receiving the service request, the responder will deserialize the first JSON string through the responder's target JSON parsing tool class and the second custom adapter, and the first Java object obtained by deserialization is determined according to the property configuration content in the second custom adapter, so that the responder can process the service request accordingly according to the first Java object. In this embodiment, since the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter, the first Java object obtained by the responder through the target JSON parsing tool class and the second custom adapter to deserialize the first JSON string is consistent with the Java object to be processed by the requester, thereby achieving universality and compatibility between different JSON parsing tool classes.

[0080] Furthermore, after the above step S20, the following steps are further included:

[0081] Step b1, obtaining a second Java object obtained by the responder processing the first Java object;

[0082] Step b2: calling a second custom adapter through the target JSON parsing tool class to serialize the second Java object to obtain a second JSON string, and feeding back the second string to the requesting party.

[0083] In this embodiment, after processing the first Java object, the responder obtains the second Java object, which is the processing result of the service request. Before the responder feeds back the processing result to the requester, the responder first serializes the second Java object through the target JSON parsing tool class and the second custom adapter to obtain the corresponding second JSON string, and then feeds back the second string to the requester. Among them, since the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter, the second JSON string serialized by the responder through the second custom adapter can be recognized by the requester, thereby further improving the versatility and compatibility between different JSON parsing tool classes.

[0084] In this embodiment, when receiving a service request sent by a requester, a target JSON parsing tool class is determined according to a preset selector, wherein the preset selector includes at least one JSON parsing tool class; the service request includes a first JSON string obtained by the requester according to a first custom adapter; the target JSON parsing tool class calls a corresponding second custom adapter to deserialize the first JSON string to obtain a first Java object, so as to process the service request according to the first Java object, wherein the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter. Therefore, even if the JSON parsing tool classes of the requester and the responder are different, the responder can still successfully deserialize the first JSON string through the adapter, thereby achieving compatibility between different JSON parsing tool classes of the requester and the responder, and further achieving the solution of the incompatibility problem caused by switching JSON parsers under the premise of modifying the code layer as little as possible.

[0085] Furthermore, based on the first embodiment of the data processing method based on JSON of the present invention, a second embodiment of the data processing method based on JSON of the present invention is proposed.

[0086] The JSON-based data processing method is applied to a distributed system, the distributed system includes the responder, and the JSON-based data processing method further includes:

[0087] Step c1, receiving a first remote transmission script, and updating a preset configuration file of the responder according to the first remote transmission script;

[0088] Step c2, performing a response operation based on the updated preset configuration file, and recording the response result in a log, wherein when the response result is a successful response, the distributed system updates the preset configuration files of other responders in the distributed system; when the response result is an abnormal response, the responder receives a second remote transmission script, and rolls back the preset configuration file of the responder according to the second remote transmission script.

[0089] In this embodiment, the concept of grayscale release is introduced. Grayscale release (also known as canary release) refers to a release method that can smoothly transition between black and white. A / B testing can be performed on it, that is, some users continue to use product feature A, and some users start to use product feature B. If users have no objection to B, then gradually expand the scope and migrate all users to B. Grayscale release can ensure the stability of the overall system. Problems can be discovered and adjusted at the initial grayscale to ensure their impact.

[0090] In the prior art, for a distributed system cluster, which may include hundreds or thousands of distributed nodes, these distributed nodes share a set of JSON parsers. The existing solution switches the underlying JSON components to Gson or Jackson in a one-size-fits-all manner. If a Json message compatibility problem occurs after the parser is switched, the entire distributed system will be unavailable, causing serious impact on user services. If you want to use the previous parser again, you need to modify the underlying code again, and the cost and loss caused are immeasurable.

[0091] In view of this situation, this embodiment applies the JSON-based data processing method to a distributed system through grayscale publishing, and the distributed system includes the current responder. Specifically, when the developer needs to switch the JSON parser for all distributed nodes in the distributed system, he can pre-write a set of first remote transmission scripts containing preset configuration files, and send the script to the responder first, and the responder updates the responder's preset configuration file according to the preset configuration file in the script. Subsequently, the responder can determine the new target JSON parsing tool class according to the tool class identifier in the updated preset configuration file, and then when processing the service request, the new target JSON parsing tool class is called to perform corresponding response operations on it, and the response results are recorded in the log, so that the distributed system can determine the scope of the grayscale release according to the response results in the log.

[0092] Specifically, if the response result of the responder is a successful response, it means that the current responder has not generated any abnormal problems such as compatibility due to the parser switching, and the scope of the grayscale release can be expanded, that is, a first remote transmission script is sent to other responders in the distributed system to update the preset configuration files of other responders in the distributed system; if the response result of the responder is an abnormal response, it means that the current responder has generated abnormal problems such as compatibility due to the parser switching. If the parser continues to be used, it may cause more serious impact. Therefore, the distributed system will send a second remote transmission script to the responder at this time. The second remote transmission script may include the preset configuration file before the responder switched, and may also include a configuration file corresponding to another parser that will not generate an abnormal response, so that the responder can roll back the responder's parser or switch to another parser that will not generate an abnormal response according to the second remote transmission script.

[0093] This embodiment can control the abnormal impact caused by parser switching within a small range through grayscale release, and combined with the above-mentioned embodiments, it can achieve rapid response to abnormal impacts and reduce the losses caused by abnormal impacts.

[0094] The present invention also provides a data processing device based on JSON, referring to Figure 3 , the JSON-based data processing device comprises:

[0095] The determination module 10 is used to determine the target JSON parsing tool class according to a preset selector when receiving a service request sent by a requester, wherein the preset selector includes at least one JSON parsing tool class; the service request includes a first JSON string obtained by the requester according to a first custom adapter;

[0096] The processing module 20 is used to call the corresponding second custom adapter through the target JSON parsing tool class to deserialize the first JSON string to obtain a first Java object, so as to process the service request according to the first Java object, wherein the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter.

[0097] Optionally, the determining module is further used to:

[0098] The preset configuration file is read regularly by the timing polling thread in the preset selector, and the value of the pointer variable in the preset selector is determined according to the tool class identifier in the preset configuration file;

[0099] The value of the pointer variable in the preset selector is obtained, and the target JSON parsing tool class is determined according to the value of the pointer variable.

[0100] Optionally, the determining module is further used to:

[0101] If the preset configuration file is not read, the JSON parsing tool class used by the responder when processing the service request most recently is used as the target JSON parsing tool class.

[0102] Optionally, the determining module is further used to:

[0103] If it is determined according to the tool class identifier in the preset configuration file that the value of the pointer variable in the preset selector has changed, the change is recorded in the log.

[0104] Optionally, the JSON-based data processing device further includes:

[0105] An object acquisition module, used to acquire a second Java object obtained by the responder processing the first Java object;

[0106] The serialization module is used to call the second custom adapter through the target JSON parsing tool class to serialize the second Java object, obtain a second JSON string, and feed back the second string to the requester.

[0107] Optionally, the JSON-based data processing device further includes:

[0108] The setting module is used to set the attribute configuration content of the first custom adapter and the attribute configuration content of the second custom adapter according to the attribute configuration instruction when receiving the attribute configuration instruction, so that the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter.

[0109] Optionally, the JSON-based data processing device further includes:

[0110] A receiving module, configured to receive a first remote transmission script, and update a preset configuration file of the responder according to the first remote transmission script;

[0111] An execution module is used to perform a response operation based on an updated preset configuration file and record the response result in a log, wherein when the response result is a successful response, the distributed system updates the preset configuration files of other responders in the distributed system; when the response result is an abnormal response, the responder receives a second remote transmission script and rolls back the preset configuration file of the responder according to the second remote transmission script.

[0112] The methods executed by the above-mentioned program units can refer to the various embodiments of the data processing method based on JSON of the present invention, which will not be described in detail here.

[0113] The present invention also provides a JSON-based data processing device, which includes: a memory, a processor, and a JSON-based data processing program stored in the memory and executable on the processor. The method implemented when the JSON-based data processing program is executed by the processor can refer to the various embodiments of the JSON-based data processing method of the present invention, which will not be repeated here.

[0114] The invention also provides a computer storage medium.

[0115] A JSON-based data processing program is stored on the computer storage medium of the present invention, and when the JSON-based data processing program is executed by a processor, the steps of the JSON-based data processing method described above are implemented.

[0116] Among them, the method implemented when the JSON-based data processing program running on the processor is executed can refer to the various embodiments of the JSON-based data processing method of the present invention, and will not be repeated here.

[0117] It should be noted that, in this article, the term "includes", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprising a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0118] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0119] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0120] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.< / object> < / t> < / t> < / t> < / object>

Claims

1. A data processing method based on JSON, characterized in that: The JSON-based data processing method is applied to a distributed system, the distributed system includes a responder, and the JSON-based data processing method includes: When receiving a service request sent by a requester, determining a target JSON parsing tool class according to a preset selector, wherein the preset selector includes at least one JSON parsing tool class; the service request includes a first JSON string obtained by the requester according to a first custom adapter; Deserialize the first JSON string by calling the corresponding second custom adapter through the target JSON parsing tool class to obtain a first Java object, so as to process the service request according to the first Java object, wherein the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter; When switching the JSON parser for all distributed nodes in the distributed system, the JSON-based data processing method includes: receiving a first remote transmission script, and updating a preset configuration file of the responder according to the first remote transmission script; Execute a response operation based on the updated preset configuration file, and record the response result in a log, wherein when the response result is a successful response, the distributed system updates the preset configuration files of other responders in the distributed system; when the response result is an abnormal response, the distributed system sends a second remote transmission script to the responder, so that the responder can roll back the preset configuration file of the responder according to the second remote transmission script; Wherein, before the step of determining the target JSON parsing tool class according to the preset selector, it also includes: The preset configuration file is read regularly by the timing polling thread in the preset selector, and the value of the pointer variable in the preset selector is determined according to the tool class identifier in the preset configuration file; The step of determining the target JSON parsing tool class according to the preset selector includes: The value of the pointer variable in the preset selector is obtained, and the target JSON parsing tool class is determined according to the value of the pointer variable.

2. The JSON-based data processing method according to claim 1, characterized in that: After the step of periodically reading the preset configuration file through the periodic polling thread in the preset selector, the method further includes: If the preset configuration file is not read, the JSON parsing tool class used by the responder when processing the service request most recently is used as the target JSON parsing tool class.

3. The JSON-based data processing method according to claim 1, characterized in that: After the step of determining the value of the pointer variable in the preset selector according to the tool class identifier in the preset configuration file, the method further includes: If it is determined according to the tool class identifier in the preset configuration file that the value of the pointer variable in the preset selector has changed, the change is recorded in the log.

4. The JSON-based data processing method according to claim 1, characterized in that: After the step of obtaining the first Java object to process the service request according to the first Java object, the method further includes: Acquire a second Java object obtained by the responder processing the first Java object; The second Java object is serialized by calling a second custom adapter through the target JSON parsing tool class to obtain a second JSON string, and the second JSON string is fed back to the requesting party.

5. The JSON-based data processing method according to claim 1, characterized in that: Before the step of determining the target JSON parsing tool class according to the preset selector upon receiving the service request sent by the requester, the method further includes: When the attribute configuration instruction is received, the attribute configuration content of the first custom adapter and the attribute configuration content of the second custom adapter are set according to the attribute configuration instruction so that the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter.

6. A data processing device based on JSON, characterized in that: The JSON-based data processing device comprises: A determination module, configured to determine a target JSON parsing tool class according to a preset selector upon receiving a service request sent by a requester, wherein the preset selector includes at least one JSON parsing tool class; the service request includes a first JSON string obtained by the requester according to a first custom adapter; A processing module, configured to deserialize the first JSON string by calling the corresponding second custom adapter through the target JSON parsing tool class to obtain a first Java object, so as to process the service request according to the first Java object, wherein the property configuration content of the first custom adapter is consistent with the property configuration content of the second custom adapter; The determination module is used to periodically read a preset configuration file through a timed polling thread in the preset selector, determine the value of a pointer variable in the preset selector according to a tool class identifier in the preset configuration file; obtain the value of the pointer variable in the preset selector, and determine a target JSON parsing tool class according to the value of the pointer variable; The processing module is used to receive a first remote transmission script, update a preset configuration file of a responder according to the first remote transmission script; perform a response operation based on the updated preset configuration file, and record the response result in a log, wherein when the response result is a successful response, the distributed system updates the preset configuration files of other responders in the distributed system; when the response result is an abnormal response, the distributed system sends a second remote transmission script to the responder, so that the responder can roll back the preset configuration file of the responder according to the second remote transmission script.

7. A JSON-based data processing device, characterized in that: The JSON-based data processing device includes: a memory, a processor, and a JSON-based data processing program stored in the memory and executable on the processor. When the JSON-based data processing program is executed by the processor, the steps of the JSON-based data processing method according to any one of claims 1 to 5 are implemented.

8. A computer storage medium, characterized in that: The computer storage medium stores a JSON-based data processing program, which, when executed by a processor, implements the steps of the JSON-based data processing method according to any one of claims 1 to 5.