CN112433709A - JSON-based data processing method, device, equipment and medium - Google Patents

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

Info

Publication number
CN112433709A
CN112433709A CN202011413471.7A CN202011413471A CN112433709A CN 112433709 A CN112433709 A CN 112433709A CN 202011413471 A CN202011413471 A CN 202011413471A CN 112433709 A CN112433709 A CN 112433709A
Authority
CN
China
Prior art keywords
json
data processing
preset
based data
tool class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011413471.7A
Other languages
Chinese (zh)
Inventor
彭云霄
刘建波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN202011413471.7A priority Critical patent/CN112433709A/en
Publication of CN112433709A publication Critical patent/CN112433709A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to the technical field of financial technology (Fintech), and discloses a data processing method based on JSON, which comprises the following steps: determining a target analysis tool class according to a preset selector when a service request sent by a requester is received, wherein the preset selector comprises at least one analysis tool class; the service request comprises a first character string obtained by the requester according to the first custom adapter; and calling a corresponding second custom adapter through the target analysis tool class to perform deserialization on the first character string to obtain a first Java object, so as to process the service request according to the first Java object, wherein the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter. Therefore, when the JSON analysis tool classes of the requester and the responder are different, the responder can still successfully deserialize the first character string through the adapter, and the compatibility of the different JSON analysis tool classes of the requester and the responder is realized.

Description

JSON-based data processing method, device, equipment and medium
Technical Field
The invention relates to the technical field of financial technology (Fintech), in particular to a JSON-based data processing method, a JSON-based data processing device, JSON-based data processing equipment and a computer storage medium.
Background
With the development of computer technology, more and more technologies (big data, distributed, artificial intelligence, etc.) are applied to the financial field, and the traditional financial industry is gradually changing to financial technology (Fintech), but because of the requirements of security and universality of the financial industry, higher requirements are also put forward on the data processing technology based on JSON.
FastJson as a JSON analysis library of the Alababa open source is widely pursued by domestic developers due to the characteristics of high analysis speed, wide use, complete functions and the like. But in the later use process, the source code quality is found to be poor, the JSON standard is not strictly followed, and the more important point is that the security vulnerability is successively exploded, and developers are forced to face a frequent process of repairing the vulnerability by updating versions. In fact, the characteristic of high analysis speed is not obvious in comparison with other JSON analysis libraries, but a developer suffers from the pain of no guarantee of system safety for a long time, so that the best scheme is to abandon FastJson and replace the FastJson with safer Gson or Jackson.
Most existing schemes for replacing JSON (java server object) parsing are implemented by directly modifying JSon utility classes to switch underlying JSON components to Gson or Jackson in a one-step mode, so that a traditional scheme can only fixedly use one JSON parser to parse messages on machines in a distributed system, if the parser needs to be changed to the distributed machines in the distributed system, a large area of modification is needed, even the whole underlying codes are replaced, the workload is large, and in addition, the scheme can possibly cause message transmission between an old machine using a FastJson parser and a new machine using the Gson parser or Jackson parser in the gray scale issuing process, and the two JSON pars are different in serialization and deserialization processing processes and cannot be compatible with each other, so that the service request parsing fails, and finally service unavailability is caused.
Disclosure of Invention
The invention mainly aims to provide a JSON-based data processing method, a JSON-based data processing device, JSON-based data processing equipment and a computer storage medium, and aims to solve the technical problem of incompatibility caused by switching JSON resolvers.
In order to achieve the above object, the present invention provides a data processing method based on JSON, which includes the following steps:
when a service request sent by a requester is received, determining a target JSON analysis tool class according to a preset selector, wherein the preset selector comprises at least one JSON analysis tool class; the service request comprises a first JSON character string obtained by the requester according to a first custom adapter;
and calling a corresponding second custom adapter through the target JSON analysis tool class to perform deserialization on the first JSON character string to obtain a first Java object, and processing the service request according to the first Java object, wherein the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter.
Optionally, before the step of determining the target JSON parsing tool class according to the preset selector, the method further includes:
reading a preset configuration file at regular time through a timing polling thread in the preset selector, and determining the value of a pointer variable in the preset selector according to a tool type identifier in the preset configuration file;
the step of determining the target JSON analysis tool class according to the preset selector comprises the following steps:
and acquiring the value of the pointer variable in the preset selector, and determining a target JSON analysis tool class according to the value of the pointer variable.
Optionally, after the step of periodically reading the preset configuration file by the timed polling thread in the preset selector, the method further includes:
and if the preset configuration file is not read, taking the JSON analysis tool class used by the responder when the responder processes the service request for the last time as the target JSON analysis tool class.
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:
and if the value of the pointer variable in the preset selector is determined to be changed according to the tool type identification in the preset configuration file, recording the change in a log.
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:
acquiring a second Java object obtained by processing the first Java object by a responder;
and calling a second custom adapter through the target JSON analysis tool class to serialize the second Java object to obtain a second JSON character string, and feeding the second character string back to the requester.
Optionally, before the step of determining the target JSON parsing tool class according to the preset selector when receiving the service request sent by the requester, the method further includes:
and when an attribute configuration instruction is received, setting 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, so that the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter.
Optionally, the JSON-based data processing method is applied to a distributed system, where the distributed system includes the responder, and the JSON-based data processing method further includes:
receiving a first remote transmission script, and updating a preset configuration file of the responder according to the first remote transmission script;
executing response operation based on the updated preset configuration file, and recording a 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; and 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.
Further, to achieve the above object, the present invention also provides a JSON-based data processing apparatus including:
the system comprises a determining module, a judging module and a judging module, wherein the determining module is used for determining a target JSON (java server object notation) analysis tool class according to a preset selector when a service request sent by a requester is received, and the preset selector comprises at least one JSON analysis tool class; the service request comprises a first JSON character string obtained by the requester according to a first custom adapter;
and the processing module is used for calling a corresponding second custom adapter through the target JSON analysis tool class to perform deserialization on the first JSON character string to obtain a first Java object so as to process the service request according to the first Java object, wherein the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter.
In addition, to achieve the above object, the present invention also provides a JSON-based data processing device, including: a memory, a processor, and a JSON-based data processing program stored on the memory and executable on the processor, the JSON-based data processing program when executed by the processor implementing the steps of the JSON-based data processing method as described above.
Further, to achieve the above object, the present invention also provides a computer storage medium having stored thereon a JSON-based data processing program that, when executed by a processor, implements the steps of the JSON-based data processing method as described above.
The method comprises the steps that when a service request sent by a requester is received, a target JSON analysis tool class is determined according to a preset selector, wherein the preset selector comprises at least one JSON analysis tool class; the service request comprises a first JSON character string obtained by the requester according to a first custom adapter; and calling a corresponding second custom adapter through the target JSON analysis tool class to perform deserialization on the first JSON character string to obtain a first Java object, and processing the service request according to the first Java object, wherein the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter. Therefore, even under the condition that JSON analysis tool classes of a requester and a responder are different, the responder can still successfully perform deserialization on the first JSON character string through the adapter, so that the compatibility of different JSON analysis tool classes of the requester and the responder is realized, and the problem of incompatibility caused by switching JSON analyzers is solved on the premise of modifying code layers as little as possible.
Drawings
FIG. 1 is a schematic diagram of a JSON-based data processing device of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a JSON-based data processing method according to a first embodiment of the present invention;
FIG. 3 is a schematic diagram of device modules of the JSON-based data processing device according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, fig. 1 is a schematic diagram of a JSON-based data processing device of a hardware operating environment according to an embodiment of the present invention.
The JSON-based data processing equipment in the embodiment of the invention can be a PC (personal computer) or server equipment, and a Java virtual machine runs on the JSON-based data processing equipment.
As shown in fig. 1, 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, a communication bus 1002. Wherein a communication bus 1002 is used to enable connective 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, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the JSON-based data processing device architecture shown in fig. 1 does not constitute a limitation of devices and may include more or fewer components than shown, or some components in combination, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a JSON-based data processing program.
In the JSON-based data processing device shown in fig. 1, the network interface 1004 is mainly used for connecting to a backend server and performing data communication with the backend server; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and the processor 1001 may be configured to call a JSON-based data processing program stored in the memory 1005 and perform operations in the JSON-based data processing method described below.
Based on the hardware structure, the embodiment of the data processing method based on JSON is provided.
JSON: is a lightweight data exchange format that stores and represents data in a text format that is completely independent of the programming language. The compact and clear hierarchy makes JSON an ideal data exchange language. The network transmission efficiency is effectively improved, and the network transmission efficiency is easy to read, write, analyze and generate.
Referring to fig. 2, fig. 2 is a schematic flowchart of a JSON-based data processing method according to a first embodiment of the present invention, where the method includes:
step S10, when a service request sent by a requester is received, determining a target JSON analysis tool class according to a preset selector, wherein the preset selector comprises at least one JSON analysis tool class; the service request comprises a first JSON character string obtained by the requester according to a first custom adapter;
the data transmission method is applied to data processing equipment based on JSON, and the data processing equipment based on JSON can be a terminal, a robot or PC equipment.
In the prior art, most of JSON analysis replacing schemes are implemented by directly modifying JSonUtil tools to switch underlying JSON members to Gson or Jackson in a one-cut manner, so that the traditional scheme can only fixedly use one JSON analyzer to analyze messages on machines in a distributed system, if the analyzer is switched on the distributed machine in the distributed system, large-area modification is needed, even the whole underlying code is replaced, the workload is large, and the scheme can possibly cause message transmission between an old machine using a FastJson analyzer and a new machine using the Gson analyzer or Jackson analyzer in the gray scale issuing process, and finally cause the analysis failure of service requests due to different serialization and deserialization processing processes of the two JSON analyzers, and the two JSON analyzers cannot be compatible with each other, so that the unavailable service is finally caused
In this context, when receiving a service request from a requestor, the present embodiment determines a target JSON parsing tool class in an optional JSON parsing tool class according to a preset selector, then the JSON character string contained in the service request is deserialized through a second adapter corresponding to the tool class, since the JSON string is serialized through the first adapter by the requestor, and the attribute configuration of the first custom adapter is the same as the attribute configuration of the second custom adapter, therefore, even under the condition that the JSON resolving tool classes of the requester and the responder are different, the responder still can successfully perform deserialization on the first JSON character string through the adapter, thereby realizing the compatibility of the different requesters and responders of the JSON resolving tool classes, and furthermore, the incompatibility problem caused by switching the JSON resolver is solved on the premise of modifying the code layer as little as possible.
It will be appreciated that when two interacting parties are in remote communication, various types of data may be transmitted between each other, but whatever type of data is transmitted over the network in binary sequences.
In this embodiment, the sender needs to convert the Java object into a binary sequence (i.e., JSON string) through a JSON parser, and the process is Serialization (Serialization) to transmit on the network; the receiver needs to restore the received binary sequence to an object through a JSON parser, and the process is deserialization (deserialization) to process the binary sequence.
Before step S10, to facilitate the operation, the JSON parser is packaged as a JSON parsing tool class, and then the JSON parsing tool class is used to perform serialization of Java objects and deserialization of JSON character strings, and 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 JSON util _ FastJson, and the custom adapter of the JSON util _ FastJson is FastJson interpreter; the JSON analysis tool class obtained by packaging the Gson analyzer is JsonUtil _ Gson, and the custom adapter of the JsonUtil _ Gson is Gson adapter; the JSON analysis tool class obtained by packaging the Jackson analyzer is JsonUtil _ Jackson, and the custom adapter of the JsonUtil _ Jackson is Jackson adapter.
In addition, a corresponding custom adapter is set for the JSON parsing tool class during packaging, and developers can respectively set the data formats of serialization and deserialization output in a custom manner through the custom adapter, for example, custom processing is performed on multiple data formats such as BigDecimal, bigdingeger, Double, Long and the like, for example, the last two digits of a decimal point are output.
It can be understood that, in this embodiment, the JSON parser of the requester and the responder may be any parser in fastjsson, Gson, and Jackson, and of course, other JSON parsers may also be used, and this embodiment does not specifically limit the type of the JSON parser. The JSON resolvers of the requestor and responder may be the same or different.
It should be noted that whatever JSON parsing tool class includes several general methods of serialization and deserialization, for example:
string format WithPresty (Object o); serializing the object;
string FormatArgs (Object [ ] args); serializing the array object;
string format List (List < Object > List); serializing the list object;
string format Pkg (Map < String, Object > request); serializing the communication message;
< T > String FormatEntity (T entry); serializing the object;
< T > String format EntityWithClassName (T entry); serializing the object;
map < String, Object > part (strings s); deserializing the map object;
object [ ] pars Args (String argsJsons); deserializing the array object;
< T > T partEntity (String s, Type); deserializing an object, which may specify an object type;
list < Object > parselist (strings s); deserializing the list object.
The above is only an example of the general method, and does not limit the general method, and developers may set the general method as needed, and the general methods may be general methods that follow the existing general methods. It will be appreciated that the generic method is actually a description of the results of the serialization or deserialization, but the specific implementation is made by the target JSON resolution tool classes determined by the selector, each of which can implement the generic method, but the processes implemented may differ.
Further, before step S10, the method further includes:
a1, reading a preset configuration file at regular time through a timing polling thread in the preset selector, and determining the value of a pointer variable in the preset selector according to a tool type identifier in the preset configuration file;
correspondingly, the step of determining the target JSON parsing tool class according to the preset selector specifically includes:
step a2, obtaining the value of the pointer variable in the preset selector, and determining a target JSON analysis tool class according to the value of the pointer variable.
In this embodiment, the preset selector is actually a json ultil factory class, and the selector includes a timed polling thread and a pointer variable, where the timed polling thread can read a preset configuration file (json. Then, when a service request sent by a requester is received, the selector can determine a target JSON analysis tool class according to the value of the pointer variable at the current moment, wherein the preset configuration file is set by a developer according to needs and uploaded to a responder, and the JSON analysis tool class can be dynamically switched by setting the preset configuration file.
For example, if Gson is identified in JSON, the value of the pointer variable is set to point to JSON util _ Gson, and correspondingly, if a service request is received at this time, the selector takes the JSON util _ Gson as a target JSON analysis tool class; if FastJson is identified in JSON, setting the value of the pointer variable to point to JsonUtil _ FastJson, and correspondingly, if a service request is received at the moment, using the JsonUtil _ FastJson as a target JSON analysis tool class by the selector; if Jackson is identified in JSON, the value of the pointer variable is set to point to JSON util _ Jackson, and correspondingly, if a service request is received at the moment, the selector takes the JSON util _ Jackson as a target JSON analysis tool class.
According to the scheme, the dynamic setting of the JSON analysis tool classes can be realized on the premise that codes are not changed in all offices, and the codes do not need to be changed globally, so that the hot switching of the JSON analysis tool classes can be realized, and the switching efficiency of the JSON analysis tool classes is improved.
Further, if the developer does not upload the preset configuration file to the responder, which indicates that the developer does not specify the JSON parsing tool class at this time, the timed polling thread will not read the tool class identifier in the preset configuration file, and certainly, under other abnormal reading conditions, the timed polling thread may not read the tool class identifier in the preset configuration file, and at this time, the original JSON parsing tool class may be continuously used, that is, the JSON parsing tool class used by the responder when processing the service request for the last time is used as the target JSON parsing tool class, so that the service abnormality caused by the fact that the tool class identifier in the preset configuration file cannot be read is avoided.
Further, after the step a1, the method further includes:
and if the value of the pointer variable in the preset selector is determined to be changed according to the tool type identification in the preset configuration file, recording the change in a log.
In this embodiment, after determining the value of the pointer variable according to the tool class identifier read by the timed polling thread, comparing the value of the pointer variable with the value of the pointer variable determined according to the tool class identifier read by the timed polling thread last time, determining whether the two values are the same, and if so, indicating that the developer does not change the JSON analysis tool class in this period of time; if the difference is different, the developer is explained in the period of time and the tool class identification in the preset configuration file is changed, so that the developer can conveniently check whether the switching of the JSON analysis tool class is successful or not, and the change of the pointer can be recorded in a log. For example, Current JSON Parser switched to Gson/Gastjson/Jackson.
Step S20, a corresponding second custom adapter is called through the target JSON analysis tool class to perform deserialization on the first JSON character string to obtain a first Java object, and the service request is processed according to the first Java object, wherein the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter.
In this embodiment, whether it is a requester or a responder, when receiving external data as a receiver or sending data to the outside as a sender, it is necessary to perform data format conversion on the received data and the sent data through the custom adapter corresponding to the current JSON parsing tool class.
Specifically, before sending a service request to a responder, a requester serializes Java objects to be processed through a JSON parsing tool class of the requester and a first custom adapter, and a data format of a first JSON character string obtained through serialization is determined according to attribute configuration contents in the first custom adapter, then the requester sends the service request containing the first JSON character string to the responder, after the responder receives the service request, the first JSON character string is deserialized through a target JSON parsing tool class of the responder and a second custom adapter, and the first Java object obtained through deserialization is determined according to attribute configuration contents in the second custom adapter, so that the responder performs corresponding processing on the service request according to the first Java object. In this embodiment, since the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter, the first Java object obtained by the responder performing deserialization on the first JSON character string through the target JSON parsing tool class and the second custom adapter is consistent with the Java object to be processed of the requester, so that the universality and compatibility between different JSON parsing tool classes can be realized.
Further, after the step S20, the method further includes:
step b1, acquiring a second Java object obtained by processing the first Java object by a responder;
step b2, a second custom adapter is called through the target JSON analysis tool class to serialize the second Java object to obtain a second JSON character string, and the second character string is fed back to the requester.
In this embodiment, after the responder processes the first Java object, a second Java object is obtained, where the second Java object is a processing result of the service request, and 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 a corresponding second JSON character string, and then feeds back the second character string to the requester. The attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter, so that the second JSON character string serialized by the second custom adapter by the responder can be recognized by the requester, and the universality and compatibility among different JSON analysis tools can be further improved.
In the embodiment, when a service request sent by a requester is received, a target JSON analysis tool class is determined according to a preset selector, wherein the preset selector comprises at least one JSON analysis tool class; the service request comprises a first JSON character string obtained by the requester according to a first custom adapter; and calling a corresponding second custom adapter through the target JSON analysis tool class to perform deserialization on the first JSON character string to obtain a first Java object, and processing the service request according to the first Java object, wherein the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter. Therefore, even under the condition that JSON analysis tool classes of a requester and a responder are different, the responder can still successfully perform deserialization on the first JSON character string through the adapter, so that the compatibility of different JSON analysis tool classes of the requester and the responder is realized, and the problem of incompatibility caused by switching JSON analyzers is solved on the premise of modifying code layers as little as possible.
Further, based on the first embodiment of the JSON-based data processing method of the present invention, a second embodiment of the JSON-based data processing method of the present invention is proposed.
The JSON-based data processing method is applied to a distributed system, the distributed system comprises the responder, and the JSON-based data processing method further comprises the following steps:
step c1, receiving a first remote transmission script, and updating the preset configuration file of the responder according to the first remote transmission script;
step c2, executing 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; and 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.
In this embodiment, a concept of gray scale distribution is introduced, and gray scale distribution (also called gold silk sparrow distribution) is a distribution method capable of smoothly transitioning between black and white. On which a/B testing may be performed, i.e. having a part of users continue to use product property a and a part of users start to use product property B, if the users have no objection to B, the scope is gradually expanded, and all users are migrated to B. The stability of the whole system can be ensured by gray scale release, and problems can be found and adjusted in the initial gray scale so as to ensure the influence degree of the gray scale.
In the prior art, for a distributed system cluster, hundreds of distributed nodes may be included, and the distributed nodes share one set of JSON parser, in the existing scheme, a cut-off switching scheme to Gson or Jackson is performed on an underlying JSON component, if a JSON message compatibility problem occurs after the parser switching, the entire distributed system may be unavailable, which may cause a serious impact on user services, and it is necessary to modify an underlying code again if a previous parser is used, where the cost required to be consumed and the loss caused are immeasurable.
For such a situation, the JSON-based data processing method is applied to a distributed system in a gray scale publishing manner, where the distributed system includes a current responder. Specifically, when a developer needs to perform JSON parser switching on all distributed nodes in the distributed system, a set of first remote transmission scripts including a preset configuration file may be written in advance, the scripts are sent to a responder, the responder updates the preset configuration file of the responder according to the preset configuration file in the scripts, then, the responder may determine a new target JSON parsing tool class according to a tool class identifier in the updated preset configuration file, and then, when a service request is processed, a corresponding response operation is performed on the new target JSON parsing tool class by calling the new target JSON parsing tool class, and a response result is recorded in a log, so that the distributed system can determine a range of gray scale release according to the response result in the log.
Specifically, if the response result of the responder is a successful response, it is indicated that the current responder does not have the problem of abnormal compatibility and the like due to switching of the resolver, and the range of gray scale release can be expanded, that is, the first remote transmission script is sent to other responders in the distributed system, so as 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 indicates that the current responder has an abnormal problem such as compatibility due to switching of the parser, and if the parser continues to be used, a more serious influence may be caused.
In the embodiment, the abnormal influence caused by switching of the resolver can be controlled within a small range by means of gray scale release, and by combining the embodiment, the abnormal influence can be quickly dealt with, and the loss caused by the abnormal influence can be reduced.
The present invention also provides a JSON-based data processing apparatus, and with reference to fig. 3, the JSON-based data processing apparatus includes:
the system comprises a determining module 10, a judging module and a judging module, wherein the determining module is used for determining a target JSON (java server object notation) analysis tool class according to a preset selector when a service request sent by a requester is received, and the preset selector comprises at least one JSON analysis tool class; the service request comprises a first JSON character string obtained by the requester according to a first custom adapter;
and the processing module 20 is configured to call a corresponding second custom adapter through the target JSON parsing tool class to perform deserialization on the first JSON character string to obtain a first Java object, and process the service request according to the first Java object, where attribute configuration content of the first custom adapter is consistent with attribute configuration content of the second custom adapter.
Optionally, the determining module is further configured to:
reading a preset configuration file at regular time through a timing polling thread in the preset selector, and determining the value of a pointer variable in the preset selector according to a tool type identifier in the preset configuration file;
and acquiring the value of the pointer variable in the preset selector, and determining a target JSON analysis tool class according to the value of the pointer variable.
Optionally, the determining module is further configured to:
and if the preset configuration file is not read, taking the JSON analysis tool class used by the responder when the responder processes the service request for the last time as the target JSON analysis tool class.
Optionally, the determining module is further configured to:
and if the value of the pointer variable in the preset selector is determined to be changed according to the tool type identification in the preset configuration file, recording the change in a log.
Optionally, the JSON-based data processing apparatus further includes:
the object acquisition module is used for acquiring a second Java object obtained by processing the first Java object by a responder;
and the serialization module is used for calling a second custom adapter through the target JSON analysis tool class to serialize the second Java object to obtain a second JSON character string, and feeding the second character string back to the requester.
Optionally, the JSON-based data processing apparatus further includes:
and the setting module is used for setting 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.
Optionally, the JSON-based data processing apparatus further includes:
the receiving module is used for receiving a first remote transmission script and updating a preset configuration file of the responder according to the first remote transmission script;
the execution module is used for executing response operation based on the updated preset configuration file and recording a 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; and 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.
The method executed by each program unit can refer to each embodiment of the JSON-based data processing method of the present invention, and details are not described here.
The invention also provides a data processing device based on JSON, which comprises: the method for implementing the JSON-based data processing program when being executed by the processor can refer to each embodiment of the JSON-based data processing method of the present invention, and details are not repeated here.
The invention also provides a computer storage medium.
The computer storage medium of the present invention has stored thereon a JSON-based data processing program which, when executed by a processor, implements the steps of the JSON-based data processing method as described above.
The method implemented when the JSON-based data processing program running on the processor is executed may refer to various embodiments of the JSON-based data processing method of the present invention, and details thereof are not described herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A data processing method based on JSON is characterized by comprising the following steps:
when a service request sent by a requester is received, determining a target JSON analysis tool class according to a preset selector, wherein the preset selector comprises at least one JSON analysis tool class; the service request comprises a first JSON character string obtained by the requester according to a first custom adapter;
and calling a corresponding second custom adapter through the target JSON analysis tool class to perform deserialization on the first JSON character string to obtain a first Java object, and processing the service request according to the first Java object, wherein the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter.
2. The JSON-based data processing method of claim 1, wherein the step of determining the target JSON parsing tool class according to a preset selector is preceded by:
reading a preset configuration file at regular time through a timing polling thread in the preset selector, and determining the value of a pointer variable in the preset selector according to a tool type identifier in the preset configuration file;
the step of determining the target JSON analysis tool class according to the preset selector comprises the following steps:
and acquiring the value of the pointer variable in the preset selector, and determining a target JSON analysis tool class according to the value of the pointer variable.
3. The JSON-based data processing method of claim 2, wherein after the step of periodically reading the preset configuration file by the timed polling thread in the preset selector, further comprising:
and if the preset configuration file is not read, taking the JSON analysis tool class used by the responder when the responder processes the service request for the last time as the target JSON analysis tool class.
4. The JSON-based data processing method of claim 2, wherein, 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, further comprising:
and if the value of the pointer variable in the preset selector is determined to be changed according to the tool type identification in the preset configuration file, recording the change in a log.
5. The JSON-based data processing method of claim 1, wherein, after the step of obtaining a first Java object to process the service request according to the first Java object, further comprising:
acquiring a second Java object obtained by processing the first Java object by a responder;
and calling a second custom adapter through the target JSON analysis tool class to serialize the second Java object to obtain a second JSON character string, and feeding the second character string back to the requester.
6. The JSON-based data processing method according to claim 1, wherein before the step of determining the target JSON parsing tool class according to a preset selector when receiving the service request sent by the requestor, the method further comprises:
and when an attribute configuration instruction is received, setting 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, so that the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter.
7. The JSON-based data processing method according to any one of claims 1 to 6, wherein the JSON-based data processing method is applied to a distributed system including the responder, and further comprising:
receiving a first remote transmission script, and updating a preset configuration file of the responder according to the first remote transmission script;
executing response operation based on the updated preset configuration file, and recording a 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; and 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.
8. A JSON-based data processing apparatus, comprising:
the system comprises a determining module, a judging module and a judging module, wherein the determining module is used for determining a target JSON (java server object notation) analysis tool class according to a preset selector when a service request sent by a requester is received, and the preset selector comprises at least one JSON analysis tool class; the service request comprises a first JSON character string obtained by the requester according to a first custom adapter;
and the processing module is used for calling a corresponding second custom adapter through the target JSON analysis tool class to perform deserialization on the first JSON character string to obtain a first Java object so as to process the service request according to the first Java object, wherein the attribute configuration content of the first custom adapter is consistent with the attribute configuration content of the second custom adapter.
9. A JSON-based data processing device, the JSON-based data processing device comprising: memory, a processor and a JSON-based data processing program stored on the memory and executable on the processor, the JSON-based data processing program when executed by the processor implementing the steps of the JSON-based data processing method as claimed in any one of claims 1 to 7.
10. A computer storage medium having stored thereon a JSON-based data processing program that, when executed by a processor, implements the steps of the JSON-based data processing method according to any one of claims 1 to 7.
CN202011413471.7A 2020-12-03 2020-12-03 JSON-based data processing method, device, equipment and medium Pending CN112433709A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011413471.7A CN112433709A (en) 2020-12-03 2020-12-03 JSON-based data processing method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011413471.7A CN112433709A (en) 2020-12-03 2020-12-03 JSON-based data processing method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN112433709A true CN112433709A (en) 2021-03-02

Family

ID=74691258

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011413471.7A Pending CN112433709A (en) 2020-12-03 2020-12-03 JSON-based data processing method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN112433709A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114818656A (en) * 2022-06-30 2022-07-29 深圳华锐分布式技术股份有限公司 Binary file analysis method, device, equipment and medium based on gray scale upgrading

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114818656A (en) * 2022-06-30 2022-07-29 深圳华锐分布式技术股份有限公司 Binary file analysis method, device, equipment and medium based on gray scale upgrading

Similar Documents

Publication Publication Date Title
CN111083225B (en) Data processing method and device in Internet of things platform and Internet of things platform
CN111708702A (en) Simulation test method, client, server, system and readable storage medium
CN110569250B (en) Management method and device for analysis library of Internet of things network element
CN112100078B (en) Method, device and equipment for generating interface test case
CN111444088B (en) Test case calling method and device for interface test
CN110532182B (en) Automatic testing method and device for virtualization platform
CN111694620B (en) Interaction method, device and equipment of third party service and computer storage medium
CN112433709A (en) JSON-based data processing method, device, equipment and medium
CN110941655B (en) Data format conversion method and device
CN109408376B (en) Configuration data generation method, device, equipment and storage medium
CN112346980B (en) Software performance testing method, system and readable storage medium
CN113704337A (en) Metadata acquisition method and system based on dynamic loading of driver
CN110839079B (en) BI node execution method, device, equipment and medium in workflow system
WO2021093672A1 (en) Method for embedding external system, workflow system, device and computer readable storage medium
CN113742408B (en) Protobuf protocol dynamic analysis-based data interaction method
CN116298340A (en) Product defect detection method and system based on task scheduling
CN115269228A (en) Data adaptive transmission method, device, equipment and medium
CN112799930A (en) Distributed pressure testing method and system
CN111984679A (en) Access method, device, host, system and medium of hardware acceleration database
CN112346979A (en) Software performance testing method, system and readable storage medium
CN112182083A (en) File generation method, device, equipment and storage medium
CN116132534B (en) Method, device, equipment and storage medium for storing service request
CN114915549B (en) Instruction query method, device, equipment and storage medium
WO2022022446A1 (en) Log printing method, device and system
WO2023029955A1 (en) Method for printing dynamic log, and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination