CN108073391B - Method and device for transmitting and processing JSON character string - Google Patents
Method and device for transmitting and processing JSON character string Download PDFInfo
- Publication number
- CN108073391B CN108073391B CN201611038828.1A CN201611038828A CN108073391B CN 108073391 B CN108073391 B CN 108073391B CN 201611038828 A CN201611038828 A CN 201611038828A CN 108073391 B CN108073391 B CN 108073391B
- Authority
- CN
- China
- Prior art keywords
- json
- key
- character string
- substring
- key value
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/12—Use of codes for handling textual entities
- G06F40/126—Character encoding
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computing Systems (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Input From Keyboards Or The Like (AREA)
- Computer And Data Communications (AREA)
Abstract
The method comprises the steps of obtaining keys and values in the JSON character string to be transmitted at a transmitting end; determining a key of the JSON substring according to the extracted key and the value, splitting the JSON substring to be transmitted into the JSON substring according to the value and the key of the JSON substring, and obtaining a key value structure of the JSON substring to be transmitted; and sending the key value structure and the JSON substring, extracting a value from the received JSON substring at a processing end, combining the extracted value and the key value structure into a JSON string, and displaying the combined JSON string. Therefore, the JSON character string with larger data volume can be split into a plurality of sub character strings with small data volume on the premise of ensuring the integrity of the format, and meanwhile, the data key value structure and the sub character strings in the split result are transmitted step by step, so that the data response speed of the processing end is improved.
Description
Technical Field
The application relates to the field of computers, in particular to a method and equipment for transmitting and processing JSON character strings.
Background
JSON (javascript Object notification) is an international standard of lightweight text exchange protocol defined by ECMA organization, which is a text protocol, any programming language can be identified and analyzed, currently used browsers interact with website backgrounds based on HTTP (hypertext transfer protocol) protocol, data in JSON character strings are composed of keys and values, JSON is becoming a mainstream information exchange format due to readability and simplicity, for example, when a user registers at a website, the browser submits JSON data to the backstage:
therefore, the background can easily acquire the required value through two keys (keys) of the name and password, and the information exchange mode is widely adopted in both websites and mobile terminals due to convenience.
JSON is a data format based on character strings, but has the disadvantages that the complete format must be loaded and then can be parsed, and when the complete format is not loaded, whether JSON is closed or still has more keys cannot be determined, so that the incomplete character strings cannot be parsed. For example, when such a character string is acquired:
{
"name": Zhang III ",
"password":123456
at this point the last "}" has not been loaded, so it cannot be determined whether the JSON has been closed or there are still more keys (keys), so the incomplete string cannot be resolved.
When the data size of JSON is large, the JSON still needs to be completely loaded before being resolved, which increases the delay of the web page or the mobile terminal. At present, the data volume of single JSON is reduced by adopting a mode of splitting a data interface, the engineering quantity of the mode is large, and the business logic coupling with a project is serious.
Content of application
An object of the present application is to provide a method and device for transmitting and processing a JSON string, which solve the problem in the prior art that the JSON string must be analyzed after being completely loaded, improve the data response speed of a processing end, and improve user experience.
According to one aspect of the application, a method for JSON character string transmission at a transmitting end is provided, and the method comprises the following steps:
extracting keys and values in the JSON character string to be transmitted;
obtaining a key value structure of a JSON character string according to the extracted keys and values, and splitting the JSON character string into JSON substrings, wherein the JSON substrings consist of the keys and the values;
and sending the key value structure and the JSON substring.
Further, in the above method, the key value structure is a JSON sub-string obtained by nullifying the value of the key of the JSON sub-string.
Further, in the above method, sending the key value structure and the JSON substring includes:
sending the key value structure;
and after the key value structure is successfully sent, sending the JSON substring.
Further, in the above method, the key comprises:
any one of a node key, a node key path, a node-added unique key, and a node array index.
Further, after splitting the JSON string into JSON substrings, the method includes:
acquiring information of one or any combination of the number, display sequence and volume size of JSON substrings;
and determining a transmission mode for sending the JSON substring according to the acquired information.
Further, the transmission mode includes:
sequentially sending the JSON substrings in sequence;
or the JSON substring is sent in parallel.
According to another aspect of the present application, there is provided a method of JSON string processing at a processing end, the method comprising:
receiving a key value structure of a JSON character string and a JSON substring;
extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings, and displaying the combined JSON character strings.
Further, in the above method, the key value structure is a JSON string obtained by nullifying the value of the key of the JSON substring;
combining the extracted values with the key value structure into a JSON character string, comprising:
and filling the extracted value to the vacant position of the value of the key of the JSON substring in the key value structure.
Further, the key includes:
any one of a node key, a node key path, a node-added unique key, and a node array index.
Further, extracting values from the received JSON substrings, and combining the extracted values into a JSON string, including:
and extracting values from the received JSON substrings in sequence according to the display sequence of the JSON substrings, combining the extracted values and the key value structure into the JSON substrings, and displaying the combined JSON substrings after each combination.
According to another aspect of the present application, there is provided a method for network interface side JSON string transmission, the method comprising:
extracting keys and values in JSON character strings to be transmitted to a receiving end by a transmitting end;
obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings;
and sending the key value structure and the JSON substring to the receiving end.
According to another aspect of the application, a method for receiving JSON character string processing of a terminal is provided, and the method comprises the following steps:
receiving a key value structure and a JSON substring of a JSON string from a network interface;
extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings, and displaying the combined JSON character strings on a display interface.
According to another aspect of the present application, there is also provided a transmission device for JSON string transmission, the transmission device including:
the acquisition device is used for extracting keys and values in the JSON character string to be transmitted;
the splitting device is used for obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings, wherein the JSON substrings consist of the keys and the value;
and the transmission device is used for sending the key value structure and the JSON substring.
Further, in the sending device, the key value structure is a JSON string obtained by nullifying the value of the key of the JSON substring.
Further, the key includes:
any one of a node key, a node key path, a node-added unique key, and a node array index.
According to still another aspect of the present application, there is also provided a processing device for JSON string display, the processing device including:
receiving means for receiving a key value structure of a JSON string and a JSON substring;
and the merging device is used for extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings and displaying the combined JSON character strings.
Further, in the processing device, the key value structure is a JSON string obtained by nullifying a value of a key of the JSON substring;
and the merging device is used for filling the extracted value to the vacant position of the value of the key of the JSON substring in the key value structure.
Further, the key includes:
any one of a node key, a node key path, a node-added unique key, and a node array index.
According to another aspect of the present application, there is also provided a network interface terminal configured to:
extracting keys and values in JSON character strings to be transmitted to a receiving end by a transmitting end;
obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings;
and sending the key value structure and the JSON substring to the receiving end.
According to another aspect of the present application, there is also provided a receiving end configured to:
receiving a key value structure and a JSON substring of a JSON string from a network interface;
extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings, and displaying the combined JSON character strings on a display interface.
According to another aspect of the present application, there is also provided a computing-based device comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
extracting keys and values in the JSON character string to be transmitted;
obtaining a key value structure of a JSON character string according to the extracted keys and values, and splitting the JSON character string into JSON substrings, wherein the JSON substrings consist of the keys and the values;
and sending the key value structure and the JSON substring.
According to another aspect of the present application, there is also provided a computing-based device comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
receiving a key value structure of a JSON character string and a JSON substring;
extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings according to the extracted values, and displaying the combined JSON character strings.
According to the method and the device, the key and the value of the character string are obtained by analyzing the JSON character string to be transmitted at the transmitting end, so that the JSON character string to be transmitted can be conveniently and accurately split according to the key and the value to obtain the JSON substrings, and therefore the format integrity of the key and the value of each split JSON substring and the legality of the substring are guaranteed; secondly, obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings, so that the data of the split JSON substrings are complete; subsequently, the data key value structure and the plurality of JSON substrings are transmitted to a processing end. Therefore, by the transmission method of the JSON character string at the sending end, the JSON character string with larger data volume can be split into a plurality of sub character strings with small data volume on the premise of ensuring the format integrity, and meanwhile, the data key value structure and the plurality of sub character strings in the split result are transmitted step by step, so that the data response speed of the processing end is improved.
Furthermore, the JSON character string to be transmitted is split according to any one key of the JSON substrings in the node keys, the node key paths, the node adding unique keys and the node array indexes, so that the unreasonable data of the split JSON substrings can be avoided, and the data response speed of the processing end can be remarkably improved.
And further, the JSON substrings split from the JSON substrings are evaluated, one or any combination of the number, display sequence and volume of the substrings is obtained, whether the split substrings are legal is judged, and a transmission mode for sending the JSON substrings is flexibly selected according to the obtained information, so that the legality of the JSON substrings is guaranteed, and the transmission efficiency is improved.
Further, extracting values from the received JSON sub-character strings at a processing end, combining the extracted values and the key value structures into JSON character strings, displaying the combined JSON character strings after each combination until all the extracted values are combined to form the JSON character strings with complete formats; and the format integrity of the JSON character string after combination is further ensured, data is presented in a progressive loading mode, and the data response speed and the user experience of the processing end are improved.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 shows a schematic diagram of splitting a JSON string to be transmitted according to an embodiment of the present application;
FIG. 2 is an interactive flow diagram illustrating the transmission and processing of a JSON string in accordance with an aspect of the subject application;
FIG. 3 shows a schematic flow diagram of the transmission and processing of JSON strings in an embodiment of the present application;
fig. 4 shows a system block diagram of the transmission and processing of JSON strings in a further embodiment according to the present application.
The same or similar reference numbers in the drawings identify the same or similar elements.
Detailed Description
The present application is described in further detail below with reference to the attached figures.
According to an aspect of the present application, there is provided a method for JSON string transmission at a sender, the method including steps S11 to S13:
and step S11, extracting keys and values in the JSON character string to be transmitted.
In an embodiment of the present application, a JSON string conforms to a JSON string format, specifically, a JSON string is defined in "{ }", only a JSON string with a complete format can be parsed, and the JSON string defines each data type in a key-value form, such as a JSON string { "a": 1, from which key a and its corresponding value, 1, can be obtained.
According to the method for transmitting the JSON character string at the transmitting end, the key and the value in the JSON character string to be transmitted are extracted at first, so that the JSON character string to be transmitted can be accurately split subsequently according to the extracted key and value, and the JSON sub character string is obtained.
In an embodiment of the present application, the extracted keys and values in the JSON string to be transmitted may be all or partial keys and values of the JSON string, and the extracted JSON string is all or partial keys and values serving as keys and values of subsequent JSON substrings, and may be determined according to specific conditions of the JSON string, such as the size of the JSON string, the types of the keys and the values, and the like.
And step S12, obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings.
And the key value structure of the JSON character string is used for assembling each JSON substring into the JSON character string by the receiving end according to the key value structure.
In an embodiment of the application, the key of the JSON substring can be determined according to the JSON substring key and the value, the JSON substring to be transmitted is split into the JSON substring according to the value and the key of the JSON substring, and the key value structure of the JSON substring to be transmitted is obtained, wherein the key value structure is the JSON substring with the value of the key of the JSON substring set to be empty.
In an embodiment of the application, in order to ensure format integrity of the split JSON substrings, the JSON substring to be transmitted is split according to keys of the JSON substring, where the keys of the JSON substring are in a splitting manner determined according to the obtained keys and values of the JSON substring, and if the keys of the JSON substring are node keys, the JSON substring to be transmitted can be split according to the node keys, and after a plurality of JSON substrings are obtained, the JSON substrings are stored and values of each JSON substring in the JSON substring to be transmitted are set to be null, so that a key value structure of the JSON substring is obtained. It is to be understood that in other specific implementations, the content of the key value structure may be any content as long as the receiving end can assemble the JSON substrings into complete JSON strings according to the key value structure.
In the embodiment of the application, the JSON character strings are split according to the extracted keys and values, so that each split sub character string can be ensured to be a character string conforming to the JSON character string format, the format integrity of the keys and values of each split JSON sub character string and the legality of the sub character string are ensured, the JSON sub character string is formed by dividing one JSON character string into a plurality of sub character strings, each split sub character string still has a complete format, and the format integrity can be independently analyzed.
In a specific embodiment of the present application, as shown in fig. 1, a schematic diagram of splitting a JSON character string to be transmitted is shown, where a large block of JSON data is the JSON character string to be transmitted, a splitter (Parser) includes keys and values of JSON substrings, multiple JSON substrings are obtained through splitting by the splitter (Parser), for example, multiple JSON substrings are represented by child nodes C1, C2, and C3 in fig. 1, and after storing C1, C2, and C3, values (key-value) of the keys in child nodes (substrings) to be transmitted are set to null (null), so that a key value structure of the JSON character string to be transmitted is obtained, that is, a data key value structure S1.
In addition, the data of the JSON character string is defined in the '{ }', if the last '}' is not loaded completely, the format of the JSON data is illegal, when the data in the JSON is more and more huge, a part of the downloaded JSON data cannot be analyzed, so that the analysis can be performed only by waiting for the complete loading of the data, and the delay of a program is increased. Because of the limitation of the JSON format, if the JSON data is directly transmitted in blocks, the data is incomplete and cannot be analyzed. According to the method for obtaining the key value structure and the JSON character string, JSON data can be decoupled into small data blocks with complete formats, namely JSON substrings, the data of the JSON substrings are defined in { }, the format integrity of the JSON substrings is guaranteed, the processing end receives each small data block, namely the JSON substring, the JSON substrings are filled into the key value structure, the filled basic structures can be independently analyzed and displayed, the JSON substrings are displayed together without waiting for the completion of the reception of other small data blocks, the effects of receiving, processing and displaying part of the JSON substrings are achieved, and the program response speed is improved.
In an embodiment of the present application, when a network interface performs information exchange by using JSON character strings, the JSON character strings in a complete format are split into a plurality of smaller JSON substrings still having the complete format, that is, into a plurality of JSON small blocks of data still having the complete format.
And step S13, sending the key value structure and the JSON substring.
In the embodiment of the application, the JSON character string is sent after being processed into the key value structure and the substring, the data volume of the key value structure of the JSON character string is smaller than that of the JSON character string, if the value of a key without the JSON substring in the key value structure is not included, compared with the transmission of the whole JSON substring, the transmission speed when the key value structure is transmitted to the processing end is greatly improved due to the reduction of the transmission data volume, the delay of data transmission is reduced, particularly in a network interface with larger data volume, the mode of sending the key value structure and the JSON substring is adopted during information exchange, and the response speed of the processing end is greatly improved.
In addition, the JSON substring is sent to the processing end, so that the processing end combines the received key value structure and the JSON substring, complete JSON data content is displayed, and information exchange of the network interface is completed. It should be noted that the transmission of the key value structure and the JSON substring may be performed concurrently or sequentially in order.
In the embodiment of the application, the key value structure and the JSON substring of the JSON string are obtained, the key value structure and the JSON substring are separately transmitted to the processing end subsequently, the processing end does not need to wait until the JSON string is completely loaded to analyze the whole JSON string, and the processing end can analyze and display part of the JSON string as long as the key value structure and one JSON substring are completely loaded, so that the data response speed of the processing end is improved, and the user experience is improved.
In an embodiment of the present application, in step S13, the sending the key-value structure and the JSON substring may specifically include: sending a key value structure; and after the key value structure is successfully sent, sending the JSON substring. The method comprises the steps of firstly sending a key value structure without the key value of the JSON substring, wherein the data volume of the key value structure is small, the transmission speed is high, and after the key value structure is successfully sent, the JSON substring is transmitted, so that the problem that data storage space is occupied because cache memory is needed before the JSON substring is successfully sent compared with the key value structure is solved.
In an embodiment of the present application, in step S12, the key may be any one of a node key, a node key path, a node-added unique key, and a node array index. In an embodiment of the present application, the JSON character string to be transmitted is split according to any one of four ways, namely, a node key (node key path), a node key path (node key path), a node adding unique key (node adding unique key), and a node array index (node array index), so that the legitimacy, transmission efficiency, and integrity of the JSON data can be ensured. For example, a JSON character string with the volume of 1M can be split into 4 sub-character strings with the volume of 0.25M, so that the data response time of a processing end is reasonable; and the split JSON sub character strings are split into two parts of sub character strings of 0.1M and 0.9M, so that the difference between the split JSON sub character strings and the original JSON character strings which are not split is small, and the data response speed of a processing end cannot be obviously improved.
The following will describe the key and value extraction modes when the key is a node key, a node key path, a node adds a unique key or a node array index.
In an embodiment, the key value extraction process can be described by taking the key as a node key as an example.
Those skilled in the art will appreciate that JSON strings have these forms: the object is an unordered set of "'name (key)/value' pairs", one object starting with "{" (left brackets), "}" (right brackets), each "name" followed by one ": "(colon); the "(comma) separation is used between the" "'name/value' pair". A key (key) refers to the "name" in the "name/value" pair, such as a JSON string:
the names "name" and "password" are keys (keys) of the JSON character string respectively, the JSON character string is read, the keys in the JSON character string are identified according to the data format of the JSON, when one key comprises a complete { }' format, the key is a node key, and the JSON character string is split according to the identified node key.
A specific process of splitting the JSON character string S to be transmitted according to the node key is described in an embodiment below, where the JSON character string S to be transmitted is S, and the specific process is as follows:
S
when reading the character string S in the above embodiment, the obtained node keys are key1, key2, and key3, and although "content" is also a key in the character string S, it is not a node key because it does not have the original complete data format of JSON, i.e., does not include "{ }". "key 1" { }, "key 2": { }, "key 3": the inside of { } is all key-value (value), such as "content": "aabb" is a set of key-value, where "aabb" is an example in this application and does not represent a specific data amount, but merely for convenience of describing the value in the character string.
Analyzing the JSON character string S to be transmitted, acquiring all node keys (the key1, the key2 and the key3) and key-value in the S, splitting the S according to the splitting mode of the node keys to obtain a key value structure S1 and substrings C1, C2 and C3 as follows:
S1
wherein null indicates that the key-value (value) corresponding to the node key is set to null.
C1
C2
C3
After the processing end receives S1, C1, C2, and C3, the values of the keys of C1, C2, and C3 may be filled into the key value structure S1 according to the corresponding node key, so as to be merged into a complete JSON string S.
In an embodiment, the key value extraction process can be described by taking the key as a node key path as an example.
When reading the JSON character string to be transmitted, whether a node key path exists in the JSON character string can be identified, specifically, whether a node key path exists can be judged according to the reference level of the node key in the JSON character string, for example, a JSON character string is read:
node key "b" references node key "a", where node key path a- > b exists. The process of splitting the JSON character string to be transmitted by using the node key path will be described in detail in the following embodiments. The JSON character string to be transmitted is S, and the method comprises the following steps:
S
analyzing the S to obtain a key and a value, identifying that the key path of the node is 'key 1- > path- > key 2' according to the reference level of the key in the JSON character string, and determining that the splitting mode of the S is reasonable according to the splitting of the key path of the node, wherein the splitting result is as follows: the basic data structure S1 and substring C1 are represented as follows,
S1
C1
in an embodiment, the key value extraction process can be described by taking the key as a node array index as an example.
Reading the JSON character string to be transmitted to obtain a key and a value, wherein the JSON supports that an array index is used as a key of the JSON character string, and the split sub-character string carries the original array index so as to synthesize final data. The array is an ordered set of values (value), one array starts with "[" (left bracket), "]" (right bracket), the values are separated by "," (comma), "{ }" is used as a node array index in each array [ ] in the JSON string, and the JSON string is split according to the array index, the specific process is specifically described in the following embodiment, and the JSON string to be transmitted is S, as follows:
S
analyzing the S to obtain keys and values, analyzing an array of the obtained character string S to obtain three node array indexes (indexes), namely three groups of { } in the list: [ ], after obtaining the node array indexes, determining that the splitting mode of the S is reasonable according to the node array indexes, and then obtaining the splitting result: the basic data structure S1 and substring C1, substring C2 and substring C3 are represented as follows:
S1
{
"list":[]
}
C1
C2
C3
it should be noted that "0", "1" and "2" are index entries of the node array for marking the program and facilitating the modification of the subsequent program, and the "content": CCDD "," content ": RRTT" and "content": NN "do not indicate the data amount in the actual application, but are merely exemplary cases in the present application, and are used for convenience of describing the key-value in the character string.
In an embodiment, the key value extraction process can be described by taking the key as an example when the unique key is added to the node.
Reading the JSON character string to be transmitted to obtain a node key (key) of the character string, adding a unique key to the key by using a hash algorithm, and splitting the JSON character string to be transmitted by using the node adding unique key, which specifically comprises the following steps: the key-based definition randomly generates a unique identifier by using a hash algorithm, the randomly generated unique identifier replaces the same key in the character string, and the hash algorithm can ensure the uniqueness of the character string, so that the character string can be used as a unique key. In another embodiment of the present application, the JSON string to be transmitted is S, as follows:
S
analyzing the JSON character string S to be transmitted, obtaining all the node keys and key-values in the S, and adding a unique key (unique key) to the node for positioning, in the above embodiment, randomly generating a unique identifier through a hash algorithm, replacing the unique identifier with the same key in the JSON character string S to be transmitted, for example, adding a unique key "unique": d3f6f7479a07e6e3fdc4fc189e9519d3 "to position the content in" content ": asd" to complete the identification of the first "key 2" in the character string S, and adding a unique key "afb9264c98914a80c676d 902521386" to position the content in "content": ffH "to complete the identification of the second" key2 "in the character string S. Splitting the S according to a splitting mode of adding a unique key (node adding unique key) to the node to obtain a splitting result of a key value structure S1 and substrings C1 and C2:
S1
C1
C2
it should be noted that, in the above embodiment in which the JSON character string to be transmitted is split according to the node key, the node key path, the node array index, and the node add unique key, S, C1, C2, and C3 are merely examples, and it is described that a key and a value in the JSON character string to be transmitted are obtained, a key of a substring is determined according to the key and the value, that is, a splitting manner is determined, and the JSON character string is split according to the splitting manner. The method can be not limited to the four splitting modes, as long as the key and value are extracted reasonably, JSON substrings with proper sizes can be formed, and the data response speed of the processing end can be improved.
In an embodiment of the present application, those skilled in the art should understand that the splitting manner of the JSON string to be transmitted may include, but is not limited to, four manners of node key, node key path, node add unique key, and node array index, and other existing or future splitting manners of splitting the JSON string, which may occur if applicable to the present application, should also be included in the scope of the present application, and are herein incorporated by reference.
In an embodiment of the present application, in step S12, after splitting the JSON string to be transmitted into JSON substrings according to the value and the key of the JSON substring, the splitting may include: step S3, acquiring information of one or any combination of the number, display sequence and volume size of JSON substrings; and step S4, determining the transmission mode of the JSON substring according to the acquired information. In an embodiment of the present application, the evaluation of the split JSON substrings in step S3 may determine the number of JSON substrings into which the JSON string to be transmitted may be decoupled in an actual situation, and the size of each substring, so as to determine whether the splitting is reasonable, for example, if the JSON string with a size of 1M is split into two substrings with sizes of 0.1M and 0.9M, a difference between the obtained split JSON string and the original JSON string without being split is small, and it may be considered that the original JSON string may be directly transmitted without adopting a splitting manner. If the obtained 1M JSON character string is split into four sub-character strings with the volume of 0.25M, and the four split sub-character strings are transmitted, the data response time of the processing end can be obviously improved, but the display time of each sub-character string is also required to be obtained during transmission, if the display time of the sub-character string C1 in the original JSON character string is the earliest, the processing end can carry out merging on the sub-character strings according to the display time sequence, and therefore a user can be guaranteed to see normal data display contents on a webpage or a mobile terminal. Next, in step S4, the transmission method for transmitting each sub-string is determined by using the information of the sub-strings split in step S3, so as to transmit the sub-strings more reasonably and improve the data response speed of the processing end.
In the above embodiment, the transmission method may include: sequentially sending the JSON substrings in sequence; or the JSON substring is sent in parallel. In a specific embodiment of the present application, when the JSON substrings are transmitted to the processing end, each substring may be sequentially sent in sequence, for example, sent according to the display time in the information, in a specific embodiment of the present application, if the substrings into which the JSON substrings are split are C1, C2, and C3, and the data key structure is S1, the transmission time of the data key structure to the processing end is VS1/speed, wherein VS1Represents the data volume of the data key structure, speed represents the transmission speed. The display time sequence of each substring in the JSON string is C1, C2 and C3 in turn, and C is transmitted first1, C2 is transmitted after the C1 is transmitted successfully, at the moment, the processing end sequentially fills the corresponding keys according to the successively received C1, C2 and C3, and the transmission time for sequentially transmitting the plurality of substrings to the processing end sequentially is equal toi=1,……n,The data volume of the ith sub-character string is represented, speed represents the transmission speed, and the transmission time of the character string to be transmitted in the transmission mode isThereby enabling the user to see a portion of the data presentation in the shortest amount of time, e.g., the user has (V) at the delay timeS1/speed+VC1/speed) can see the data display content of C1 first, but not the data display content of C1 can be seen after the delay time is S/speed, and the data is presented in a progressive loading mode, so that the data response speed of a processing end is improved.
In another specific embodiment of the present application, in a network interface with a large data volume, the JSON character string S to be transmitted is split into a plurality of substrings, and it can be known from the information that the number of the substrings is large, and at this time, a transmission mode in which all the substrings are transmitted in parallel can be selected, so that the total transmission speed is greatly increased, and at this time, the time for transmitting the plurality of substrings in parallel is max (V)C1/speed,……,VCnSpeed), representing the longest transmission time, V, for selecting a plurality of substrings to be transmitted concurrently to the processing endCiAnd the/speed (i is 1, … … n) represents the transmission time of the ith substring to the processing end. The transmission time of the character string to be transmitted in the parallel transmission mode is VS1/speed+max(VC1/speed,……,VCn/speed), wherein VS1The speed represents the transmission time of the data key value structure to the processing end; therefore, the data transmission speed is greatly improved, and the response delay of the processing end is reduced.
According to another aspect of the present application, there is provided a method of JSON string display at a processing end, the method may include steps S21 and S22:
step S21, receiving a key value structure of the JSON character string and the JSON substring; in an embodiment of the present application, the data to be merged in step S21 is first received, that is, the data key value structure and the JSON substring are received, then the received data are merged according to a preset manner so as to be displayed to a user at a processing end, and a specific data merging process is performed in step S22, as follows:
and step S22, extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings, and displaying the combined JSON character strings.
In an embodiment of the application, a key value structure and a JSON substring of the JSON string can be obtained by extracting a key and a value in the JSON string to be transmitted by a sender, obtaining the key value structure of the JSON string according to the extracted key and the value, and splitting the JSON string into the JSON substrings, wherein the specific formats of the key value structure and the JSON substring of the JSON string can be agreed in advance by the key value structure of the JSON string and the sending and receiving party of the JSON substring, so long as the receiving party can recognize the key value structure and the content in the JSON substring after receiving the key value structure and the JSON substring of the JSON string, extract a value from the received JSON substring, and combine the extracted value with the key value structure into the JSON string.
In an embodiment of the present application, when information is exchanged in a network interface, for example, data interaction between a web page, a mobile terminal, and a server is performed, a method for splitting a JSON string to be transmitted into a key value structure and multiple JSON substrings is adopted, and the key value structure and the JSON substrings sent from a sending end need to be received and then displayed correspondingly at a processing end after being merged, so that the processing end does not need to wait until the JSON string is completely loaded, and as long as the processing end waits until the key value structure and a certain JSON substring are completely loaded, a part of the JSON string can be parsed and displayed, thereby improving data response speed of the processing end and improving user experience.
In an embodiment of the present application, the key value structure may be a JSON sub-string obtained by nulling a value of a key of the JSON sub-string, and the filling of the extracted value into the key value structure may include: and filling the extracted value to the vacant position of the value of the key of the JSON substring in the key value structure.
In an embodiment of the application, a sending end respectively transmits a data key value structure and a sub-character string, the data key value structure has no value, the JSON character string is a JSON character string with a null value of the sub-character string, therefore, a processing end needs to fill the null value in the data key value structure, in order to ensure that the JSON character string to be transmitted of the sending end is consistent with the data content finally displayed by the processing end, the accuracy of merging the data key value structure and the JSON sub-character string by the processing end needs to be ensured, therefore, firstly, the value in each JSON sub-character string is extracted from the received JSON sub-character string, the extracted value is respectively filled to the null position of the value of the key of the sub-character string in the key value structure, the format integrity of the merged ON data is ensured by matching and filling data according to the position of the key of the character string in the key value structure, the filled key value structure is displayed, namely, the merged data content is displayed, and the information interaction of the network interface is completed.
In an embodiment of the present application, step S21 may include: and after receiving the key value structure of the JSON character string to be transmitted, receiving the JSON substring. In an embodiment of the present application, in order to improve the data response speed of the processing end and reduce the storage space occupied by the data cache, after receiving the key value structure of the JSON string to be transmitted, the JSON substring is received. In an embodiment of the present application, if the JSON string to be transmitted is S,
S
the JSON character string S to be transmitted is divided into a key value structure S1 and a sub-character string according to the node key, the processing end receives the key value structure S1 firstly and then receives the sub-character string, wherein,
key value structure S1
After the key value structure S1 is successfully received, the substrings C1, C2 and C3 are received,
substring C1
Substring C2
Substring C3
Therefore, when the data amount in the sub-character strings C1, C2 and C3 is relatively large, namely, the data amount represented by "content" a "," content "B" and "content" C "is relatively large, after the key value structure S1 is successfully transmitted, the character strings C1, C2 and C3 are sequentially filled to the positions corresponding to S1, and then are combined into a complete data message format, and the data response speed of the processing end is remarkably improved.
In an embodiment of the present application, in step S22, the key may include: any one of a node key, a node key path, a node-added unique key, and a node array index. In an embodiment of the application, the value of the substring is filled to the corresponding position of the key value structure according to any one of a node key (node key), a node key path (node key path), a node adding unique key (node adding unique key) and a node array index (node array index), so that the validity and integrity of the merged JSON data can be ensured, the data can be displayed completely, and information interaction in a network interface can be completed.
Continuing to the above embodiment, the extracted value is filled to the empty position of the value corresponding to the node key in the key value structure, for example, the value of C1 is first filled to the empty position of the value of key1 in the key value structure S1, and the values of C2 and C3 are correspondingly filled to the empty positions of the values of key2 and key3 in S1, so that the data structure after all the values are filled is ensured to be consistent with the format and content of the JSON character string when the data structure is not split, and the format integrity of the data is ensured. It should be noted that, the above-mentioned filling of the value of C1 into the key-value structure S1 with the values of C2 and C3 is only a preferable example, and may also be concurrent values of C1, C2, and C3, and in an embodiment of the present application, the order of filling the values of a plurality of substrings into the key-value structure is not limited.
In an embodiment of the present application, step S22 may include: extracting values from the received JSON substrings in sequence according to the display sequence of the JSON substrings, combining the extracted values and the key value structure into the JSON substrings, displaying the combined JSON substrings after each combination, for example, filling the extracted values to the vacant positions of the values of the keys of the JSON substrings in the key value structure, and displaying the filled key value structure after each filling. Here, according to the JSON substring display order, which refers to the generation time of each substring in the JSON string when it is not originally split, for example, after the content of the existing substring C1 in the JSON string, the substring C2 is present, the value extracted from each substring is sequentially filled into the vacant position of the key value of the corresponding substring in the data key value structure, and the display is performed after each filling, so that a user can see a part of display data in the shortest time, thereby improving the user experience.
Continuing with the above embodiment, after receiving the key value structure S1 at the processing end, according to the display time sequence of C1, C2, and C3 in the JSON character string S to be transmitted, values are extracted from the substring C1, and filled to corresponding positions in S1, and the following data structure S2 is spliced:
at this time, the user sees the data content displayed by key1 in the shortest time, but cannot see the data content until S is completely loaded, the same process is performed, the value in C2 is obtained again, C2 is filled into a data structure S2 containing a C1 value, a data structure with C1 and C2 values is displayed after filling, and similarly, the value of C3 is filled, so that the process of merging the key value structure and the substring received from the transmitting end is completed, and JSON data with a complete format is formed.
FIG. 2 is a schematic diagram illustrating a method interaction flow for transmission and processing of JSON strings in accordance with an aspect of the present application; the method can comprise steps S11-S13 of a transmitting end, and steps S21 and S22 of a processing end, wherein in step S11, keys and values in a JSON character string to be transmitted are extracted; in step S12, obtaining a key value structure of a JSON string according to the extracted keys and values, and splitting the JSON string into JSON substrings, where the key value structure of the JSON string is the key value structure of the JSON string, and the JSON substrings are composed of the keys and the values; in step S13, the key-value structure and JSON substring are sent. Next, in step S21, a key value structure of the JSON string and a JSON substring are received; in step S22, a value is extracted from the received JSON substring, the extracted value and the key value structure are combined into a JSON string, and the combined JSON string is displayed.
FIG. 3 shows a schematic flow diagram of the transmission and processing of JSON strings in an embodiment of the present application; the following steps are carried out at the processing end, in step S01, the JSON character string to be transmitted is analyzed to obtain the key and the value of the character string, so that the JSON character string to be transmitted can be conveniently and accurately split according to the key and the value to obtain the JSON substring, and the format integrity of the key and the value of each split JSON substring and the legality of the substring are ensured; step S02 is carried out, a key value structure of the JSON character string is obtained according to the extracted keys and the value, and the JSON character string is split into JSON substrings, so that the data of the split JSON substrings are complete; in step S03, the data key value structure and the JSON substrings are transmitted to the processing end. Therefore, by the transmission method of the JSON character string at the sending end, the problem that the JSON character string with large data volume is split into a plurality of small blocks of data (sub character strings) on the premise of ensuring the format integrity is solved, and meanwhile, the data key value structure and the plurality of sub character strings in the split result are transmitted step by step, so that the data response speed of the processing end is improved. Then, at the processing end, extracting values from the received JSON substring in step S04, filling the extracted values into vacant positions of the values of the keys of the substring, and then, displaying the filled key value structure after each filling in step S05 until all the extracted values are filled, so as to form a JSON string with a complete format; and the format integrity of the combined JSON character string is further ensured, data is presented in a progressive loading mode at the processing end, and the data response speed and the user experience of the processing end are improved.
Furthermore, the JSON character string to be transmitted is split at the sending end according to any one of the JSON sub character strings in the node keys, the node key paths, the node adding unique keys and the node array indexes, so that the unreasonable data of the split JSON sub character string can be avoided, and the data response speed of the processing end can be remarkably improved.
Furthermore, the JSON substrings split in the JSON substrings are evaluated at the sending end, one or any combination of the number, the display sequence and the volume of the substrings is obtained, whether the split substrings are legal is judged, and the transmission mode for sending the JSON substrings is flexibly selected according to the obtained information, so that the legality of the JSON substrings is guaranteed, and the transmission efficiency is improved.
Furthermore, when merging data is carried out at a processing end, values are extracted from the received JSON substrings in sequence according to the display sequence of the JSON substrings, the extracted values are filled to the positions of keys of the JSON substrings in the key value structure, and the filled key value structure is displayed after each filling, so that a user can see a part of display data in the shortest time, and the user experience is improved.
It should be noted that the method for transmitting and displaying JSON character strings described in the present application can be applied to websites and mobile terminals in practical applications, for example, when an account is registered on a website, a browser will submit JSON data to a backend server for information exchange, and can also be used in all network interfaces using JSON data, such as a data large disk HTTP interface.
According to another aspect of the present application, there is provided a method for network interface side JSON string transmission, the method comprising: extracting keys and values in JSON character strings to be transmitted to a receiving end by a transmitting end; obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings; and sending the key value structure and the JSON substring to the receiving end.
In an embodiment of the present application, the network interface end may be an intermediary for connecting the sending end and the receiving end to perform data communication, specifically, may be a web server, and the sending end and the receiving end may be browser clients, or short message, QQ, and wechat clients, respectively, and the key value structure and the JSON substring may be separately sent to the receiving end through the network interface end.
According to another aspect of the application, a method for receiving JSON character string processing of a terminal is provided, and the method comprises the following steps: receiving a key value structure and a JSON substring of a JSON string from a network interface; extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings, and displaying the combined JSON character strings on a display interface.
In an embodiment of the application, the network interface end may be an intermediary for connecting the sending end and the receiving end to perform data communication, specifically, the network interface end may be a website server, the receiving end may be a browser client, or a short message, QQ, or WeChat client, and the receiving end may extract a value from the received JSON substring after receiving the key value structure and the JSON substring, combine the extracted value with the key value structure into the JSON substring, and display the combined JSON substring on a display interface, thereby implementing segment-by-segment display of the JSON substring and improving display efficiency.
According to another aspect of the present application, there is provided a transmission device for JSON string transmission, the transmission device may include:
and the acquisition device 11 is used for extracting keys and values in the JSON character string to be transmitted.
In an embodiment of the present application, a JSON string conforms to a JSON string format, specifically, a JSON string is defined in "{ }", only a JSON string with a complete format can be parsed, and the JSON string defines each data type in a key-value form, such as a JSON string { "a": 1, from which key a and its corresponding value, 1, can be obtained.
According to the method for transmitting the JSON character string at the transmitting end, the key and the value in the JSON character string to be transmitted are extracted at first, so that the JSON character string to be transmitted can be accurately split subsequently according to the extracted key and value, and the JSON sub character string is obtained.
In an embodiment of the present application, the extracted keys and values in the JSON string to be transmitted may be all or partial keys and values of the JSON string, and the extracted JSON string is all or partial keys and values serving as keys and values of subsequent JSON substrings, and may be determined according to specific conditions of the JSON string, such as the size of the JSON string, the types of the keys and the values, and the like.
And the splitting device 12 is used for obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings.
And the key value structure of the JSON character string is used for assembling each JSON substring into the JSON character string by the receiving end according to the key value structure.
In an embodiment of the application, the key of the JSON substring can be determined according to the JSON substring key and the value, the JSON substring to be transmitted is split into the JSON substring according to the value and the key of the JSON substring, and the key value structure of the JSON substring to be transmitted is obtained, wherein the key value structure is the JSON substring with the value of the key of the JSON substring set to be empty.
In an embodiment of the application, in order to ensure format integrity of the split JSON substrings, the JSON substring to be transmitted is split according to keys of the JSON substring, where the keys of the JSON substring are in a splitting manner determined according to the obtained keys and values of the JSON substring, and if the keys of the JSON substring are node keys, the JSON substring to be transmitted can be split according to the node keys, and after a plurality of JSON substrings are obtained, the JSON substrings are stored and values of each JSON substring in the JSON substring to be transmitted are set to be null, so that a key value structure of the JSON substring is obtained. It is to be understood that in other specific implementations, the content of the key value structure may be any content as long as the receiving end can assemble the JSON substrings into complete JSON strings according to the key value structure.
In the embodiment of the application, the JSON character strings are split according to the extracted keys and values, so that each split sub character string can be ensured to be a character string conforming to the JSON character string format, the format integrity of the keys and values of each split JSON sub character string and the legality of the sub character string are ensured, the JSON sub character string is formed by dividing one JSON character string into a plurality of sub character strings, each split sub character string still has a complete format, and the format integrity can be independently analyzed.
In a specific embodiment of the present application, as shown in fig. 1, a schematic diagram of splitting a JSON character string to be transmitted is shown, where a large block of JSON data is the JSON character string to be transmitted, a splitter (Parser) includes keys and values of JSON substrings, multiple JSON substrings are obtained through splitting by the splitter (Parser), for example, multiple JSON substrings are represented by child nodes C1, C2, and C3 in fig. 1, and after storing C1, C2, and C3, values (key-value) of the keys in child nodes (substrings) to be transmitted are set to null (null), so that a key value structure of the JSON character string to be transmitted is obtained, that is, a data key value structure S1.
In addition, the data of the JSON character string is defined in the '{ }', if the last '}' is not loaded completely, the format of the JSON data is illegal, when the data in the JSON is more and more huge, a part of the downloaded JSON data cannot be analyzed, so that the analysis can be performed only by waiting for the complete loading of the data, and the delay of a program is increased. Because of the limitation of the JSON format, if the JSON data is directly transmitted in blocks, the data is incomplete and cannot be analyzed. According to the method for obtaining the key value structure and the JSON character string, JSON data can be decoupled into small data blocks with complete formats, namely JSON substrings, the data of the JSON substrings are defined in { }, the format integrity of the JSON substrings is guaranteed, the processing end receives each small data block, namely the JSON substring, the JSON substrings are filled into the key value structure, the filled basic structures can be independently analyzed and displayed, the JSON substrings are displayed together without waiting for the completion of the reception of other small data blocks, the effects of receiving, processing and displaying part of the JSON substrings are achieved, and the program response speed is improved.
In an embodiment of the present application, when a network interface performs information exchange by using JSON character strings, the JSON character strings in a complete format are split into a plurality of smaller JSON substrings still having the complete format, that is, into a plurality of JSON small blocks of data still having the complete format.
And the transmission device 13 is used for sending the key value structure and the JSON substring.
In the embodiment of the application, the JSON character string is sent after being processed into the key value structure and the substring, the data volume of the key value structure of the JSON character string is smaller than that of the JSON character string, if the value of a key without the JSON substring in the key value structure is not included, compared with the transmission of the whole JSON substring, the transmission speed when the key value structure is transmitted to the processing end is greatly improved due to the reduction of the transmission data volume, the delay of data transmission is reduced, particularly in a network interface with larger data volume, the mode of sending the key value structure and the JSON substring is adopted during information exchange, and the response speed of the processing end is greatly improved.
In addition, the JSON substring is sent to the processing end, so that the processing end combines the received key value structure and the JSON substring, complete JSON data content is displayed, and information exchange of the network interface is completed. It should be noted that the transmission of the key value structure and the JSON substring may be performed concurrently or sequentially in order.
In the embodiment of the application, the key value structure and the JSON substring of the JSON string are obtained, the key value structure and the JSON substring are separately transmitted to the processing end subsequently, the processing end does not need to wait until the JSON string is completely loaded to analyze the whole JSON string, and the processing end can analyze and display part of the JSON string as long as the key value structure and one JSON substring are completely loaded, so that the data response speed of the processing end is improved, and the user experience is improved.
In an embodiment of the present application, the sending, by the transmission device 13, the key value structure and the JSON substring may specifically include: sending a key value structure; and after the key value structure is successfully sent, sending the JSON substring. The method comprises the steps of firstly sending a key value structure without the key value of the JSON substring, wherein the data volume of the key value structure is small, the transmission speed is high, and after the key value structure is successfully sent, the JSON substring is transmitted, so that the problem that data storage space is occupied because cache memory is needed before the JSON substring is successfully sent compared with the key value structure is solved.
In an embodiment of the present application, the key may include: any one of a node key, a node key path, a node-added unique key, and a node array index. In an embodiment of the present application, the JSON character string to be transmitted is split according to any one of four ways, namely, a node key (node key path), a node key path (node key path), a node adding unique key (node adding unique key), and a node array index (node array index), so that the legitimacy, transmission efficiency, and integrity of the JSON data can be ensured. For example, a JSON character string with the volume of 1M can be split into 4 sub-character strings with the volume of 0.25M, so that the data response time of a processing end is reasonable; and the split JSON sub character strings are split into two parts of sub character strings of 0.1M and 0.9M, so that the difference between the split JSON sub character strings and the original JSON character strings which are not split is small, and the data response speed of a processing end cannot be obviously improved.
The following will describe the key and value extraction modes when the key is a node key, a node key path, a node adds a unique key or a node array index.
In an embodiment, the key value extraction process can be described by taking the key as a node key as an example.
Those skilled in the art will appreciate that JSON strings have these forms: the object is an unordered set of "'name (key)/value' pairs", one object starting with "{" (left brackets), "}" (right brackets), each "name" followed by one ": "(colon); the "(comma) separation is used between the" "'name/value' pair". A key (key) refers to the "name" in the "name/value" pair, such as a JSON string:
the names "name" and "password" are keys (keys) of the JSON character string respectively, the JSON character string is read, the keys in the JSON character string are identified according to the data format of the JSON, when one key comprises a complete { }' format, the key is a node key, and the JSON character string is split according to the identified node key.
A specific process of splitting the JSON character string S to be transmitted according to the node key is described in an embodiment below, where the JSON character string S to be transmitted is S, and the specific process is as follows:
S
when reading the character string S in the above embodiment, the obtained node keys are key1, key2, and key3, and although "content" is also a key in the character string S, it is not a node key because it does not have the original complete data format of JSON, i.e., does not include "{ }". "key 1" { }, "key 2": { }, "key 3": the inside of { } is all key-value (value), such as "content": "aabb" is a set of key-value, where "aabb" is an example in this application and does not represent a specific data amount, but merely for convenience of describing the value in the character string.
Analyzing the JSON character string S to be transmitted, acquiring all node keys (the key1, the key2 and the key3) and key-value in the S, splitting the S according to the splitting mode of the node keys to obtain a key value structure S1 and substrings C1, C2 and C3 as follows:
S1
wherein null indicates that the key-value (value) corresponding to the node key is set to null.
C1
C2
C3
After the processing end receives S1, C1, C2, and C3, the values of the keys of C1, C2, and C3 may be filled into the key value structure S1 according to the corresponding node key, so as to be merged into a complete JSON string S.
In an embodiment, the key value extraction process can be described by taking the key as a node key path as an example.
When reading the JSON character string to be transmitted, whether a node key path exists in the JSON character string can be identified, specifically, whether a node key path exists can be judged according to the reference level of the node key in the JSON character string, for example, a JSON character string is read:
node key "b" references node key "a", where node key path a- > b exists. The process of splitting the JSON character string to be transmitted by using the node key path will be described in detail in the following embodiments. The JSON character string to be transmitted is S, and the method comprises the following steps:
S
analyzing the S to obtain a key and a value, identifying that the key path of the node is 'key 1- > path- > key 2' according to the reference level of the key in the JSON character string, and determining that the splitting mode of the S is reasonable according to the splitting of the key path of the node, wherein the splitting result is as follows: the basic data structure S1 and substring C1 are represented as follows,
S1
C1
in an embodiment, the key value extraction process can be described by taking the key as a node array index as an example.
Reading the JSON character string to be transmitted to obtain a key and a value, wherein the JSON supports that an array index is used as a key of the JSON character string, and the split sub-character string carries the original array index so as to synthesize final data. The array is an ordered set of values (value), one array starts with "[" (left bracket), "]" (right bracket), the values are separated by "," (comma), "{ }" is used as a node array index in each array [ ] in the JSON string, and the JSON string is split according to the array index, the specific process is specifically described in the following embodiment, and the JSON string to be transmitted is S, as follows:
S
analyzing the S to obtain keys and values, analyzing an array of the obtained character string S to obtain three node array indexes (indexes), namely three groups of { } in the list: [ ], after obtaining the node array indexes, determining that the splitting mode of the S is reasonable according to the node array indexes, and then obtaining the splitting result: the basic data structure S1 and substring C1, substring C2 and substring C3 are represented as follows:
S1
{
"list":[]
}
C1
C2
C3
it should be noted that "0", "1" and "2" are index entries of the node array for marking the program and facilitating the modification of the subsequent program, and the "content": CCDD "," content ": RRTT" and "content": NN "do not indicate the data amount in the actual application, but are merely exemplary cases in the present application, and are used for convenience of describing the key-value in the character string.
In an embodiment, the key value extraction process can be described by taking the key as an example when the unique key is added to the node.
Reading the JSON character string to be transmitted to obtain a node key (key) of the character string, adding a unique key to the key by using a hash algorithm, and splitting the JSON character string to be transmitted by using the node adding unique key, which specifically comprises the following steps: the key-based definition randomly generates a unique identifier by using a hash algorithm, the randomly generated unique identifier replaces the same key in the character string, and the hash algorithm can ensure the uniqueness of the character string, so that the character string can be used as a unique key. In another embodiment of the present application, the JSON string to be transmitted is S, as follows:
S
analyzing the JSON character string S to be transmitted, obtaining all the node keys and key-values in the S, and adding a unique key (unique key) to the node for positioning, in the above embodiment, randomly generating a unique identifier through a hash algorithm, replacing the unique identifier with the same key in the JSON character string S to be transmitted, for example, adding a unique key "unique": d3f6f7479a07e6e3fdc4fc189e9519d3 "to position the content in" content ": asd" to complete the identification of the first "key 2" in the character string S, and adding a unique key "afb9264c98914a80c676d 902521386" to position the content in "content": ffH "to complete the identification of the second" key2 "in the character string S. Splitting the S according to a splitting mode of adding a unique key (node adding unique key) to the node to obtain a splitting result of a key value structure S1 and substrings C1 and C2:
S1
C1
C2
it should be noted that, in the above embodiment in which the JSON character string to be transmitted is split according to the node key, the node key path, the node array index, and the node add unique key, S, C1, C2, and C3 are merely examples, and it is described that a key and a value in the JSON character string to be transmitted are obtained, a key of a substring is determined according to the key and the value, that is, a splitting manner is determined, and the JSON character string is split according to the splitting manner. The method can be not limited to the four splitting modes, as long as the key and value are extracted reasonably, JSON substrings with proper sizes can be formed, and the data response speed of the processing end can be improved.
In an embodiment of the present application, those skilled in the art should understand that the splitting manner of the JSON string to be transmitted may include, but is not limited to, four manners of node key, node key path, node add unique key, and node array index, and other existing or future splitting manners of splitting the JSON string, which may occur if applicable to the present application, should also be included in the scope of the present application, and are herein incorporated by reference.
In an embodiment of the present application, the sending device is further configured to: acquiring information of one or any combination of the number, display sequence and volume size of JSON substrings; and determining a transmission mode for sending the JSON substring according to the acquired information. In an embodiment of the present application, the number of JSON substrings into which the JSON substrings to be transmitted can be decoupled in an actual situation and the size of each substring can be determined by evaluating the split JSON substring, so that whether the splitting is reasonable or not can be determined, for example, when the JSON string with the size of 1M is split into two substrings with the sizes of 0.1M and 0.9M, a difference from an original JSON string which is not split is small, and it can be considered that the original JSON string can be directly transmitted without adopting a splitting manner. If the obtained 1M JSON character string is split into four sub-character strings with the volume of 0.25M, and the four split sub-character strings are transmitted, the data response time of the processing end can be obviously improved, but the display time of each sub-character string is also required to be obtained during transmission, if the display time of the sub-character string C1 in the original JSON character string is the earliest, the processing end can carry out merging on the sub-character strings according to the display time sequence, and therefore a user can be guaranteed to see normal data display contents on a webpage or a mobile terminal. And then, determining a transmission mode for transmitting each sub-character string by using the information of the sub-character strings split in the actual situation, thereby more reasonably transmitting the sub-character strings and improving the data response speed of a processing end.
In the above embodiment, the transmission method may include: sequentially sending the JSON substrings in sequence; or the JSON substring is sent in parallel. In a specific embodiment of the present application, when the JSON substring is transmitted to the processing end, each substring may be sequentially sent in sequence, for example, sent according to the display time in the informationThe character strings are C1, C2 and C3, the data key value structure is S1, and the transmission time for transmitting the data key value structure to the processing end is VS1/speed, wherein VS1Represents the data volume of the data key structure, speed represents the transmission speed. The display time sequence of each substring in the JSON string is sequentially C1, C2 and C3, C1 is transmitted first, C1 is transmitted successfully, then C2 is transmitted, at the moment, the processing end sequentially fills C1, C2 and C3 which are received sequentially to corresponding keys, and the transmission time for sequentially transmitting a plurality of substrings to the processing end sequentially is equal toi=1,……n,The data volume of the ith sub-character string is represented, speed represents the transmission speed, and the transmission time of the character string to be transmitted in the transmission mode isThereby enabling the user to see a portion of the data presentation in the shortest amount of time, e.g., the user has (V) at the delay timeS1/speed+VC1/speed) can see the data display content of C1 first, but not the data display content of C1 can be seen after the delay time is S/speed, and the data is presented in a progressive loading mode, so that the data response speed of a processing end is improved.
In another specific embodiment of the present application, in a network interface with a large data volume, the JSON character string S to be transmitted is split into a plurality of substrings, and it can be known from the information that the number of the substrings is large, and at this time, a transmission mode in which all the substrings are transmitted in parallel can be selected, so that the total transmission speed is greatly increased, and at this time, the time for transmitting the plurality of substrings in parallel is max (V)C1/speed,……,VCnSpeed), representing the longest transmission time, V, for selecting a plurality of substrings to be transmitted concurrently to the processing endCiAnd the/speed (i is 1, … … n) represents the transmission time of the ith substring to the processing end. Then the parallel transmissionThe transmission time of the character string to be transmitted is VS1/speed+max(VC1/speed,……,VCn/speed), wherein VS1The speed represents the transmission time of the data key value structure to the processing end; therefore, the data transmission speed is greatly improved, and the response delay of the processing end is reduced.
According to another aspect of the present application, there is also provided a processing device for JSON string display, the processing device may include:
and the receiving device 21 is used for receiving the key value structure of the JSON character string to be transmitted and the JSON substring. In an embodiment of the present application, first, in step S21, data to be merged is received, that is, a data key value structure and a JSON substring are received, then, the received data are merged according to a preset manner so as to be displayed to a user at a processing end, and a specific data merging process is performed in the merging device 22, as follows:
the merging device 22 is configured to extract a value from the received JSON substring, combine the extracted value with the key value structure into a JSON string, and display the combined JSON string, so that the processing end does not need to wait until the JSON string is completely loaded to parse the entire JSON string, and the processing end can parse and display a part of the JSON string as long as the processing end waits until the key value structure and a certain JSON substring are completely loaded, thereby improving the data response speed of the processing end and improving the user experience.
In an embodiment of the application, a key value structure and a JSON substring of the JSON string can be obtained by extracting a key and a value in the JSON string to be transmitted by a sender, obtaining the key value structure of the JSON string according to the extracted key and the value, and splitting the JSON string into the JSON substrings, wherein the specific formats of the key value structure and the JSON substring of the JSON string can be agreed in advance by the key value structure of the JSON string and the sending and receiving party of the JSON substring, so long as the receiving party can recognize the key value structure and the content in the JSON substring after receiving the key value structure and the JSON substring of the JSON string, extract a value from the received JSON substring, and combine the extracted value with the key value structure into the JSON string.
In an embodiment of the present application, if the key value structure is a JSON string obtained by nulling a value of a key of the JSON substring, filling the extracted value into the key value structure may include: and filling the extracted value to the vacant position of the value of the key of the JSON substring in the key value structure.
In an embodiment of the application, a sending end respectively transmits a data key value structure and a sub-character string, the data key value structure has no value, the JSON character string is obtained by emptying the value of the sub-character string, therefore, a processing end needs to fill the emptied value in the data key value structure, in order to ensure that the JSON character string to be transmitted of the sending end is consistent with the data content finally displayed by the processing end, the accuracy of merging the data key value structure and the JSON sub-character string by the processing end needs to be ensured, therefore, firstly, the value in each JSON sub-character string is extracted from the received JSON sub-character string, the extracted value is respectively filled to the emptied position of the value of the key of the sub-character string in the key value structure, in the embodiment of the application, the filling data is matched according to the position of the key of the character string in the key value structure, the format integrity of the merged JSON data is ensured, the filled key value structure is displayed after all the, namely, the merged data content is displayed, and the information interaction of the network interface is completed.
In an embodiment of the present application, the receiving device 21 is configured to: and after receiving the key value structure of the JSON character string to be transmitted, receiving the JSON substring. In an embodiment of the present application, in order to improve the data response speed of the processing end and reduce the storage space occupied by the data cache, after receiving the key value structure of the JSON string to be transmitted, the JSON substring is received. In an embodiment of the present application, if the JSON string to be transmitted is S,
S
the JSON character string S to be transmitted is divided into a key value structure S1 and a sub-character string according to the node key, the processing end receives the key value structure S1 firstly and then receives the sub-character string, wherein,
key value structure S1
After the key value structure S1 is successfully received, the substrings C1, C2 and C3 are received,
substring C1
Substring C2
Substring C3
Therefore, when the data amount in the sub-character strings C1, C2 and C3 is relatively large, namely, the data amount represented by "content" a "," content "B" and "content" C "is relatively large, after the key value structure S1 is successfully transmitted, the character strings C1, C2 and C3 are sequentially filled to the positions corresponding to S1, and then are combined into a complete data message format, and the data response speed of the processing end is remarkably improved.
In an embodiment of the present application, the key may include: any one of a node key, a node key path, a node-added unique key, and a node array index. In an embodiment of the application, the value of the substring is filled to the corresponding position of the key value structure according to any one of a node key (node key), a node key path (node key path), a node adding unique key (node adding unique key) and a node array index (node array index), so that the validity and integrity of the merged JSON data can be ensured, the data can be displayed completely, and information interaction in a network interface can be completed.
Continuing to the above embodiment, the extracted value is filled to the empty position of the value corresponding to the node key in the key value structure, for example, the value of C1 is first filled to the empty position of the value of key1 in the key value structure S1, and the values of C2 and C3 are correspondingly filled to the empty positions of the values of key2 and key3 in S1, so that the data structure after all the values are filled is ensured to be consistent with the format and content of the JSON character string when the data structure is not split, and the format integrity of the data is ensured. It should be noted that, the above-mentioned filling of the value of C1 into the key-value structure S1 with the values of C2 and C3 is only a preferable example, and may also be concurrent values of C1, C2, and C3, and in an embodiment of the present application, the order of filling the values of a plurality of substrings into the key-value structure is not limited.
In an embodiment of the present application, the merging device 22 is configured to: extracting values from the received JSON substrings in sequence according to the display sequence of the JSON substrings, combining the extracted values and the key value structure into the JSON substrings, displaying the combined JSON substrings after each combination, for example, filling the extracted values to the vacant positions of the values of the keys of the JSON substrings in the key value structure, and displaying the filled key value structure after each filling. Here, according to the JSON substring display order, which refers to the generation time of each substring in the JSON string when it is not originally split, for example, after the content of the existing substring C1 in the JSON string, the substring C2 is present, the value extracted from each substring is sequentially filled into the vacant position of the key value of the corresponding substring in the data key value structure, and the display is performed after each filling, so that a user can see a part of display data in the shortest time, thereby improving the user experience. Continuing to the above embodiment, after receiving the key value structure S1 at the processing end, according to the display time sequence of C1, C2, and C3 in the JSON character string S to be transmitted, values are extracted from the substring C1, and filled to the empty positions of the corresponding values in S1, and the following data structure S2 is spliced:
at this time, the user sees the data content displayed by key1 in the shortest time, but cannot see the data content until S is completely loaded, the same process is performed, the value in C2 is obtained again, C2 is filled into a data structure S2 containing a C1 value, a data structure with C1 and C2 values is displayed after filling, and similarly, the value of C3 is filled, so that the process of merging the key value structure and the substring received from the transmitting end is completed, and JSON data with a complete format is formed.
FIG. 3 shows a system block diagram of the transmission and processing of JSON strings in accordance with yet another embodiment of the present application; the system may comprise a transmitting device 1 and a processing device 2; the sending device may include an obtaining means 11, a splitting means 12 and a transmitting means 13; the acquisition device 11 extracts keys and values in the JSON character string to be transmitted; the splitting device 12 obtains a key value structure of the JSON character string according to the extracted keys and values, and splits the JSON character string into JSON sub-character strings, wherein the key value structure of the JSON character string is the key value structure of the JSON character string, and the JSON sub-character strings consist of the keys and the values; the transmission means 13 sends the key value structure and JSON substring. The processing device 2 may comprise a receiving means 21 and a merging means 22, the receiving means 21 receiving a key value structure of a JSON string and a JSON substring; the merging device 22 extracts a value from the received JSON substring, combines the extracted value with the key value structure into a JSON string, and displays the combined JSON string.
Specifically, the method comprises the following steps: the acquisition device 11 is used for analyzing the JSON character string to be transmitted to obtain a key and a value of the character string, so that the JSON character string to be transmitted can be conveniently and accurately split according to the key and the value to obtain JSON substrings, and the format integrity of the key and the value of each split JSON substring and the legality of the substring are guaranteed; the splitting device 12 is configured to obtain a key value structure of the JSON character string according to the extracted key and the value, and split the JSON character string into JSON substrings, so that data of the multiple split JSON substrings is complete; and the transmission device 13 is used for transmitting the data key value structure and the JSON substrings to the processing end. Therefore, by the transmission method of the JSON character string at the sending end, the problem that the JSON character string with large data volume is split into a plurality of small blocks of data (sub character strings) on the premise of ensuring the format integrity is solved, and meanwhile, the data key value structure and the plurality of sub character strings in the split result are transmitted step by step, so that the data response speed of the processing end is improved. Then, after the receiving device 21 receives the key value structure of the JSON character string to be transmitted and the JSON substring, the merging device 22 extracts a value from the received JSON substring, fills the extracted value to the vacant position of the value of the key of the substring, and then the merging device 22 is further configured to display the filled key value structure after each filling until all the extracted values are filled, so as to form the JSON character string with a complete format; and the format integrity of the combined JSON character string is further ensured, data is presented in a progressive loading mode at the processing end, and the data response speed and the user experience of the processing end are improved.
Further, in the embodiment of the transmission device for the JSON string described in the present application, the JSON string to be transmitted is split according to any one of the keys of the node key, the node key path, the node adding unique key, and the node array index, so that the irrational data of the split JSON substring can be avoided, and the data response speed of the processing end can be significantly improved.
Further, in an embodiment of the transmission device for transmitting the JSON sub-string described in the present application, the JSON sub-strings split in the JSON sub-string are evaluated, information of one or any combination of the number, display order, and volume of the sub-strings is obtained, whether the split sub-strings are legal is judged, and a transmission mode for transmitting the JSON sub-strings is flexibly selected according to the obtained information, so that the validity of the JSON sub-strings is ensured, and the transmission efficiency is improved.
Further, in an embodiment of the processing device for displaying a JSON string described in the present application, when merging data, values are sequentially extracted from the received JSON substrings according to a display order of the JSON substrings, the extracted values are filled to positions of keys of the JSON substrings in the key value structure, and the filled key value structure is displayed after each filling, so that a user can see a part of display data in the shortest time, and user experience is improved.
It should be noted that the method for transmitting and displaying JSON character strings in the sending device and the processing device described in the present application may be applied to websites and mobile terminals in practical applications, for example, when an account is registered on a website, a browser may submit JSON data to a background server for information exchange, and may also be used in all network interfaces which use JSON data and can perform data interaction, such as a data large disk HTTP interface.
According to another aspect of the present application, there is also provided a network interface terminal configured to: extracting keys and values in JSON character strings to be transmitted to a receiving end by a transmitting end; obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings; and sending the key value structure and the JSON substring to the receiving end.
In an embodiment of the present application, the network interface end may be an intermediary for connecting the sending end and the receiving end to perform data communication, specifically, may be a web server, and the sending end and the receiving end may be browser clients, or short message, QQ, and wechat clients, respectively, and the key value structure and the JSON substring may be separately sent to the receiving end through the network interface end.
According to another aspect of the present application, there is also provided a receiving end configured to: receiving a key value structure and a JSON substring of a JSON string from a network interface; extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings, and displaying the combined JSON character strings on a display interface.
In an embodiment of the application, the network interface end may be an intermediary for connecting the sending end and the receiving end to perform data communication, specifically, the network interface end may be a website server, the receiving end may be a browser client, or a short message, QQ, or WeChat client, and the receiving end may extract a value from the received JSON substring after receiving the key value structure and the JSON substring, combine the extracted value with the key value structure into the JSON substring, and display the combined JSON substring on a display interface, thereby implementing segment-by-segment display of the JSON substring and improving display efficiency.
According to another aspect of the present application, there is also provided a computing-based device comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
extracting keys and values in the JSON character string to be transmitted;
obtaining a key value structure of a JSON character string according to the extracted keys and values, and splitting the JSON character string into JSON substrings, wherein the JSON substrings consist of the keys and the values;
and sending the key value structure and the JSON substring.
According to another aspect of the present application, there is also provided a computing-based device comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
receiving a key value structure of a JSON character string and a JSON substring;
extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings according to the extracted values, and displaying the combined JSON character strings. It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, implemented using Application Specific Integrated Circuits (ASICs), general purpose computers or any other similar hardware devices. In one embodiment, the software programs of the present application may be executed by a processor to implement the steps or functions described above. Likewise, the software programs (including associated data structures) of the present application may be stored in a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. Additionally, some of the steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
In addition, some of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application through the operation of the computer. Program instructions which invoke the methods of the present application may be stored on a fixed or removable recording medium and/or transmitted via a data stream on a broadcast or other signal-bearing medium and/or stored within a working memory of a computer device operating in accordance with the program instructions. An embodiment according to the present application may comprise an apparatus, which may comprise a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to perform a method and/or a solution according to the aforementioned embodiments of the present application.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the apparatus claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Claims (22)
1. A method of JSON string transmission, wherein the method comprises:
extracting keys and values in the JSON character string to be transmitted;
obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings; dividing the JSON character string into JSON sub character strings with a complete JSON data format according to keys of the JSON data format, and emptying the value of each divided JSON sub character string to obtain the key value structure;
and sending the key value structure and the JSON substring.
2. The method of claim 1 wherein the key-value structure is a JSON substring with values of keys of the JSON substring nulled.
3. The method of claim 1, wherein sending the key-value structure and JSON substring comprises:
sending the key value structure;
and after the key value structure is successfully sent, sending the JSON substring.
4. The method of claim 1, wherein the key comprises:
any one of a node key, a node key path, a node-added unique key, and a node array index.
5. The method of claim 1, wherein splitting the JSON string into JSON substrings comprises, after:
acquiring information of one or any combination of the number, display sequence and volume size of JSON substrings;
and determining a transmission mode for sending the JSON substring according to the acquired information.
6. The method of claim 5, wherein the transmission mode comprises:
sequentially sending the JSON substrings in sequence;
or the JSON substring is sent in parallel.
7. A method of JSON string processing, wherein the method comprises:
receiving a key value structure of a JSON character string and a JSON substring; the method comprises the steps that a sending end divides a JSON character string into JSON sub character strings with a complete JSON data format according to keys of the JSON data format, and nulls the value of each divided JSON sub character string to obtain a key value structure;
extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings, and displaying the combined JSON character strings.
8. The method of claim 7 wherein the key-value structure is a JSON substring with values of keys of the JSON substring nulled;
combining the extracted values with the key value structure into a JSON character string, comprising:
and filling the extracted value to the vacant position of the value of the key of the JSON substring in the key value structure.
9. The method of claim 7, wherein the key comprises:
any one of a node key, a node key path, a node-added unique key, and a node array index.
10. The method of claim 7, wherein extracting values from the received JSON substring, combining the extracted values with the key-value structure into a JSON string comprises:
and extracting values from the received JSON substrings in sequence according to the display sequence of the JSON substrings, combining the extracted values and the key value structure into the JSON substrings, and displaying the combined JSON substrings after each combination.
11. A method for transmitting JSON character strings at a network interface end, wherein the method comprises the following steps:
extracting keys and values in JSON character strings to be transmitted to a receiving end by a transmitting end;
obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings; dividing the JSON character string into JSON sub character strings with a complete JSON data format according to keys of the JSON data format, and emptying the value of each divided JSON sub character string to obtain the key value structure;
and sending the key value structure and the JSON substring to the receiving end.
12. A method for receiving JSON character string processing at a terminal, wherein the method comprises the following steps:
receiving a key value structure and a JSON substring of a JSON string from a network interface; the method comprises the steps that a sending end divides a JSON character string into JSON sub character strings with a complete JSON data format according to keys of the JSON data format, and nulls the value of each divided JSON sub character string to obtain a key value structure;
extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings, and displaying the combined JSON character strings on a display interface.
13. A transmitting device, wherein the transmitting device comprises:
the acquisition device is used for extracting keys and values in the JSON character string to be transmitted;
the splitting device is used for obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON sub character strings; dividing the JSON character string into JSON sub character strings with a complete JSON data format according to keys of the JSON data format, and emptying the value of each divided JSON sub character string to obtain the key value structure;
and the transmission device is used for sending the key value structure and the JSON substring.
14. The transmitting device of claim 13 wherein the key value structure is a JSON substring with values of keys of the JSON substring nulled.
15. The transmitting device of claim 13, wherein the key comprises:
any one of a node key, a node key path, a node-added unique key, and a node array index.
16. A processing device, wherein the processing device comprises:
receiving means for receiving a key value structure of a JSON string and a JSON substring; the method comprises the steps that a sending end divides a JSON character string into JSON sub character strings with a complete JSON data format according to keys of the JSON data format, and nulls the value of each divided JSON sub character string to obtain a key value structure;
and the merging device is used for extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings and displaying the combined JSON character strings.
17. The processing device of claim 16, wherein the key value structure is a JSON substring with values of keys of the JSON substring nulled;
and the merging device is used for filling the extracted value to the vacant position of the value of the key of the JSON substring in the key value structure.
18. The processing device of claim 16, wherein the key comprises:
any one of a node key, a node key path, a node-added unique key, and a node array index.
19. A network interface port, wherein to:
extracting keys and values in JSON character strings to be transmitted to a receiving end by a transmitting end;
obtaining a key value structure of the JSON character string according to the extracted keys and the value, and splitting the JSON character string into JSON substrings; dividing the JSON character string into JSON sub character strings with a complete JSON data format according to keys of the JSON data format, and emptying the value of each divided JSON sub character string to obtain the key value structure;
and sending the key value structure and the JSON substring to the receiving end.
20. A receiving end, wherein, configured to:
receiving a key value structure and a JSON substring of a JSON string from a network interface; the method comprises the steps that a sending end divides a JSON character string into JSON sub character strings with a complete JSON data format according to keys of the JSON data format, and nulls the value of each divided JSON sub character string to obtain a key value structure;
extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings, and displaying the combined JSON character strings on a display interface.
21. A computing-based device, comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
extracting keys and values in the JSON character string to be transmitted;
obtaining a key value structure of a JSON character string according to the extracted keys and values, and splitting the JSON character string into JSON substrings, wherein the JSON substrings consist of the keys and the values; dividing the JSON character string into JSON sub character strings with a complete JSON data format according to keys of the JSON data format, and emptying the value of each divided JSON sub character string to obtain the key value structure;
and sending the key value structure and the JSON substring.
22. A computing-based device, comprising:
a processor; and
a memory arranged to store computer executable instructions that, when executed, cause the processor to:
receiving a key value structure of a JSON character string and a JSON substring; the method comprises the steps that a sending end divides a JSON character string into JSON sub character strings with a complete JSON data format according to keys of the JSON data format, and nulls the value of each divided JSON sub character string to obtain a key value structure;
extracting values from the received JSON sub-character strings, combining the extracted values and the key value structures into JSON character strings, and displaying the combined JSON character strings.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611038828.1A CN108073391B (en) | 2016-11-11 | 2016-11-11 | Method and device for transmitting and processing JSON character string |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611038828.1A CN108073391B (en) | 2016-11-11 | 2016-11-11 | Method and device for transmitting and processing JSON character string |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108073391A CN108073391A (en) | 2018-05-25 |
CN108073391B true CN108073391B (en) | 2021-06-22 |
Family
ID=62161372
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611038828.1A Active CN108073391B (en) | 2016-11-11 | 2016-11-11 | Method and device for transmitting and processing JSON character string |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108073391B (en) |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109144514B (en) * | 2018-06-11 | 2021-06-18 | 玖富金科控股集团有限责任公司 | JSON format data analysis and storage method and device |
CN109032724B (en) * | 2018-06-29 | 2022-06-24 | 武汉斗鱼网络科技有限公司 | Method, device, terminal and storage medium for processing user-defined bullet screen message |
CN108882006A (en) * | 2018-07-03 | 2018-11-23 | 武汉斗鱼网络科技有限公司 | A kind of conversion method of message format, device, storage medium and android terminal |
CN111061927B (en) * | 2018-10-16 | 2023-06-20 | 阿里巴巴集团控股有限公司 | Data processing method and device and electronic equipment |
CN109766100A (en) * | 2018-12-11 | 2019-05-17 | 新华三技术有限公司合肥分公司 | Data processing method and device |
CN110046288A (en) * | 2019-04-19 | 2019-07-23 | 新华三技术有限公司 | The method and device of data is extracted from message body |
CN111177484A (en) * | 2019-12-09 | 2020-05-19 | 贵阳语玩科技有限公司 | System and method for loading and managing different data sources and format character string resource files |
CN111581456A (en) * | 2020-05-09 | 2020-08-25 | 深圳市卡数科技有限公司 | JSON character string comparison method, device, equipment and storage medium |
CN116610679B (en) * | 2023-07-17 | 2023-10-17 | 金锐同创(北京)科技股份有限公司 | json data analysis method, json data analysis device, computer equipment and computer medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101930455A (en) * | 2010-07-30 | 2010-12-29 | 南京莱斯信息技术股份有限公司 | Structured data exchanging method |
CN104216958A (en) * | 2014-08-20 | 2014-12-17 | 深圳市邦彦信息技术有限公司 | Transmission method and device based on structured data |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2014133542A2 (en) * | 2013-03-01 | 2014-09-04 | Empire Technology Development Llc | Idempotent representation of numbers in extensible languages |
-
2016
- 2016-11-11 CN CN201611038828.1A patent/CN108073391B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101930455A (en) * | 2010-07-30 | 2010-12-29 | 南京莱斯信息技术股份有限公司 | Structured data exchanging method |
CN104216958A (en) * | 2014-08-20 | 2014-12-17 | 深圳市邦彦信息技术有限公司 | Transmission method and device based on structured data |
Also Published As
Publication number | Publication date |
---|---|
CN108073391A (en) | 2018-05-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108073391B (en) | Method and device for transmitting and processing JSON character string | |
US10795629B2 (en) | Text and custom format information processing method, client, server, and computer-readable storage medium | |
CN107015948B (en) | Log information formatting method and system | |
CN104063401B (en) | The method and apparatus that a kind of webpage pattern address merges | |
US20150074758A1 (en) | Method of using a mobile terminal to implement cloud searching | |
CN109842629A (en) | The implementation method of custom protocol based on protocol analysis frame | |
US20080313291A1 (en) | Method and apparatus for encoding data | |
CN104580310A (en) | Log processing method and server | |
CN116634046A (en) | Message processing method and device, electronic equipment and storage medium | |
CN108809896A (en) | A kind of information calibration method, device and electronic equipment | |
US9871715B2 (en) | System and method for automated generation of web decoding templates | |
CN117540374A (en) | File scanning method and device | |
CN112994900A (en) | File countersigning method, device, client, server and storage medium | |
CN116127945A (en) | Network link processing method and device, electronic equipment and storage medium | |
CN110730964B (en) | Custom user cues for auto-fill applications | |
CN110020246B (en) | Terminal identification information generation method and related equipment | |
CN114039801B (en) | Short link generation method, short link analysis system, short link analysis equipment and storage medium | |
CN111985186B (en) | Dictionary item conversion method, API gateway system, equipment and storage medium | |
CN109344344A (en) | Identification method, server and the computer readable storage medium of webpage client | |
CN109657184B (en) | Rich text processing method, rich text processing device, server and computer readable medium | |
CN107643978A (en) | The method and apparatus of function of application test | |
CN113204449A (en) | Session backup method, computer-readable storage medium and terminal device | |
CN108809900B (en) | Framework and method for unified resource access | |
CN107707328B (en) | Abstract information transmission method and device | |
CN113010588A (en) | Data table processing method |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |