CN106649634A - JSON data analysis method and device - Google Patents

JSON data analysis method and device Download PDF

Info

Publication number
CN106649634A
CN106649634A CN201611121521.8A CN201611121521A CN106649634A CN 106649634 A CN106649634 A CN 106649634A CN 201611121521 A CN201611121521 A CN 201611121521A CN 106649634 A CN106649634 A CN 106649634A
Authority
CN
China
Prior art keywords
data
json
type
json data
types
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201611121521.8A
Other languages
Chinese (zh)
Inventor
张磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN201611121521.8A priority Critical patent/CN106649634A/en
Publication of CN106649634A publication Critical patent/CN106649634A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Storage Device Security (AREA)

Abstract

The invention discloses a JSON data analysis method which is applied to a JSON data analysis device. The JSON data analysis method comprises the steps that JSON data and data type information corresponding to the JSON data are acquired; a specific data type is determined on the basis of the data type information, wherein the specific data type is the type of a data object that the JSON data needs to be converted; the JSON data is converted into the data object with the specific data type; the data object with the specific data type is returned. Accordingly, the technical problem that in the prior art, analysis errors are likely to be generated due to the fact that the JSON data is analyzed in a manual mode is solved. The invention further discloses the JSON data analysis device.

Description

A kind of method and device of parsing JSON data
Technical field
The present invention relates to technical field of software development, more particularly to a kind of method and device of parsing JSON data.
Background technology
In App (Application, application) development process, typically can be using to network communication module, network service mould Block is frequently used for transmitting JSON numbers by HTTP (Hyper Text Transport Protocol, HTTP) According to.When JSON data are received, developer is generally required according to specific data-interface to the JSON numbers that receive According to being parsed, then the JSON data for having parsed are Resealed into data object to be further processed.
Due to the difference of data object, conventional scheme is all that developer oneself parses to JSON data, then will solution The data of analysis are packaged into corresponding data object.Use of this process in App development processes is very frequently, to lead to every time Letter process causes exploitation to need constantly to write resolving due to the difference of data type, significantly increases developer Workload.Simultaneously because being continuously increased for code quantity, causes later maintenance also to be difficult to safeguard, and it is wrong parsing easily occur By mistake.
The content of the invention
The embodiment of the present application is solved in prior art and adopted by providing a kind of method and device of parsing JSON data Artificial mode is parsed to JSON data, there is the technical problem for parsing mistake easily occur.
On the one hand, the application provides following technical scheme by an embodiment of the application:
A kind of method of parsing JSON data, in being applied to the device for parsing JSON data, including:
Obtain JSON data;
Obtain data type information corresponding with the JSON data;
Based on the data type information, specified data type is determined, the specified data type is the JSON numbers According to the type of the data object for needing to be converted into;
The JSON data are converted to into the data object of the specified data type.
Preferably, the specified data type, including:
Integer Integer types;Or
Lint-long integer Long types;Or
Floating number Float type;Or
Object Objcet types.
Preferably, before determining specified data type, also included based on the data type information described:
Judge whether the JSON data are empty, wherein, the JSON data are String types;
If not it is empty, then remove the space in the JSON data.
Preferably, the data object that the JSON data are converted to the specified data type, including:
If the specified data type is Integer types, call Integer.valueOf (msg) functions will be described Data object of the JSON data conversions into Integer types;Or
If the specified data type is Long types, Long.valueOf (msg) functions are called by the JSON numbers According to the data object for being converted into Long types;Or
If the specified data type is Float types, Float.valueOf (msg) functions are called by the JSON Data object of the data conversion into Float types;Or
If the specified data type is Objcet types, JSON.parseObject (msg, clazz) function is called By the JSON data conversions into Objcet types data object.
Preferably, the acquisition JSON data, including:
Encryption data is received, the encryption data is encrypted using predetermined encryption mode;
Based on default manner of decryption corresponding with the predetermined encryption side, the encryption data is decrypted, obtains institute State JSON data.
Preferably, the predetermined encryption mode, specially:
Obtain current time;
The current time is taken the remainder to 10, the last two digits of the current time are obtained, and will be described last Two digits are used as key value;
Extract each character in the JSON data;
Obtain the corresponding ASCII character of each character in the JSON data;
The corresponding ASCII character of each character in the JSON data is deducted into the key value, the encryption is obtained Data.
Preferably, it is described based on default manner of decryption corresponding with the predetermined encryption side, the encryption data is carried out Decryption, obtains the JSON data, including:
Obtain current time;
The current time is taken the remainder to 10, the last two digits of the current time are obtained, and will be described last Two digits are used as key value;
Extract each character in the encryption data;
Obtain the corresponding ASCII character of each character in the encryption data;
The corresponding ASCII character of each character in the encryption data is added into the key value, the JSON is obtained Data.
Preferably, the acquisition current time, including:
System.currentTimeMillis () function is called to obtain the current time.
On the other hand, based on same inventive concept, the embodiment that the application passes through the application, there is provided following technical side Case:
A kind of device of parsing JSON data, including:
Acquiring unit, for obtaining JSON data and data type information corresponding with the JSON data;
Determining unit, for based on the data type information, determining specified data type, the specified data type is The type of the data object for needing to be converted into for the JSON data;
Converting unit, for the JSON data to be converted to the object of the specified data type;
Returning unit, for returning the data object of the specified data type.
Preferably, the specified data type, including:
Integer Integer types;Or
Lint-long integer Long types;Or
Floating number Float type;Or
Object Objcet types.
Preferably, the device of the parsing JSON data, also includes:
Judging unit, based on the data type information, before determining specified data type, judges described for described Whether JSON data are empty, wherein, the JSON data are String types;
Removal unit, for if not sky, then remove the space in the JSON data.
Preferably, the converting unit, including:
First conversion subunit, if being Integer types for the specified data type, calls Integer.valueOf (msg) functions by the JSON data conversions into Integer types data object;Or
Second conversion subunit, if being Long types for the specified data type, calls Long.valueOf (msg) function by the JSON data conversions into Long types data object;Or
3rd conversion subunit, if being Float types for the specified data type, calls Float.valueOf (msg) function by the JSON data conversions into Float types data object;Or
4th conversion subunit, if being Objcet types for the specified data type, calls JSON.parseObject (msg, clazz) functions by the JSON data conversions into Objcet types data object.
Preferably, the acquiring unit, including:
Receiving subelement, for receiving encryption data, the encryption data is encrypted using predetermined encryption mode;
Decryption subelement, for based on default manner of decryption corresponding with the predetermined encryption side, to the encryption data It is decrypted, obtains the JSON data.
Preferably, the predetermined encryption mode, specially:
Obtain current time;The current time is taken the remainder to 10, the last two digits of the current time are obtained, And using the last two digits as key value;Extract each character in the JSON data;Obtain the JSON data In the corresponding ASCII character of each character;The corresponding ASCII character of each character in the JSON data is deducted into the pass Key assignments, obtains the encryption data.
Preferably, the decryption subelement, specifically for:
Obtain current time;The current time is taken the remainder to 10, the last two digits of the current time are obtained, And using the last two digits as key value;Extract each character in the encryption data;Obtain the encryption data In the corresponding ASCII character of each character;The corresponding ASCII character of each character in the encryption data is added into the pass Key assignments, obtains the JSON data.
Preferably, the decryption subelement, specifically for:
System.currentTimeMillis () function is called to obtain the current time.
One or more technical schemes provided in the embodiment of the present application, at least have the following technical effect that or advantage:
1st, in embodiments of the present invention, a kind of method of parsing JSON data is disclosed, is applied to parse JSON data In device, including:Obtain JSON data and data type information corresponding with the JSON data;Based on the data type Information, determines specified data type, and the specified data type is the data object that the JSON data needs are converted into Type;The JSON data are converted to into the data object of the specified data type.Due to JSON data can be turned automatically Change any object data into, without the need for developer the process that JSON is changed oneself is realized again, reduce the probability for parsing mistake occur. In so as to solve prior art JSON data are parsed by the way of artificial, there is the skill for parsing mistake easily occur Art problem.Realizing reduces the probability of parsing JSON data appearance parsing mistakes, and calls simple, easy to use technology effect Really.
2nd, in embodiments of the present invention, this programme is enabled by the JSON data of String types by using for general type It is converted into any type of data object.
3rd, in embodiments of the present invention, the resolving of JSON data is encapsulated, the durability of code is substantially increased.
4th, in embodiments of the present invention, it is intelligent that data are judged, without the need for artificially going again according to different types manually Different analysis modes are called, the workload of developer is reduced.
5th, in embodiments of the present invention, by self-defining encipher-decipher method, can effectively ensure that JSON data are being passed Security in defeated.
Description of the drawings
Technical scheme in order to be illustrated more clearly that the embodiment of the present invention, below will be to making needed for embodiment description Accompanying drawing is briefly described, it should be apparent that, drawings in the following description are some embodiments of the present invention, for this For the those of ordinary skill of field, on the premise of not paying creative work, can be with other according to these accompanying drawings acquisitions Accompanying drawing.
Fig. 1 is a kind of flow chart of the method for parsing JSON data in the embodiment of the present invention;
Fig. 2 is a kind of structure chart of the device of parsing JSON data in the embodiment of the present invention.
Specific embodiment
The embodiment of the present application is solved in prior art and adopted by providing a kind of method and device of parsing JSON data Artificial mode is parsed to JSON data, there is the technical problem for parsing mistake easily occur.
The technical scheme of the embodiment of the present application is to solve above-mentioned technical problem, and general thought is as follows:
A kind of method of parsing JSON data, in being applied to the device for parsing JSON data, including:Obtain JSON data with And data type information corresponding with the JSON data;Based on the data type information, specified data type is determined, it is described Specified data type is the type of the data object that the JSON data need to be converted into;The JSON data are converted to into institute State the data object of specified data type.
In order to be better understood from above-mentioned technical proposal, below in conjunction with Figure of description and specific embodiment to upper State technical scheme to be described in detail.
Embodiment one
A kind of method of parsing JSON data is present embodiments provided, in being applied to the device of a parsing JSON data, should Device can operate in electronic equipment (for example;Computer or palm PC or, smart mobile phone etc.) on an application program.
As shown in figure 1, the parsing JSON data, including:
Step S101:Obtain JSON data and data type information corresponding with JSON data.
JSON:English full name is JavaScript Object Notation, is a kind of data interchange format of lightweight. Its a subset based on ECMAScript.JSON is adopted and is totally independent of the text formatting of language, but be also using similar In the custom (including C, C++, C#, Java, JavaScript, Perl, Python etc.) of C language family.
In specific implementation process, the JSON data for getting are String (character string) type data, and the JSON data can To be developer's typing, or receive miscellaneous equipment (for example:Server) send.
As a kind of optional embodiment, step S101, including:Encryption data is received, encryption data is added using default Close mode is encrypted;Based on default manner of decryption corresponding with predetermined encryption side, encryption data is decrypted, obtains JSON Data.
In specific implementation process, for the consideration of confidentiality, transmitting terminal, can be using encryption when JSON data are sent Mode to retransmiting after JSON data encryptions.
As a kind of optional embodiment, the predetermined encryption mode, specifically refer to:(unit is to obtain current time: Millisecond);Current time is taken the remainder to 10, the last two digits of current time are obtained, and using last two digits as pass Key assignments key;Extract each character in JSON data;Obtain the corresponding ASCII character of each character in JSON data;By JSON The corresponding ASCII character of each character in data deducts key value key, obtains encryption data.
In specific implementation process, when system.currentTimeMillis () function can be called to obtain current Between, what the current timetable showed is the current computer time with inquiry (0 during year January of Greenwich Mean Time, i.e., 1970 No. 10 Point 0 second) the millisecond number that differed from.
In specific implementation process, JSON data are String type data, can extract each character in JSON data, The corresponding ASCII character of each character in JSON data is obtained again (for example:The ASCII character of character " a " is digital " 97 ", character The ASCII character of " b " is digital " 98 ", and the ASCII character of character c is digital " 99 ", etc.).
Accordingly, receiving terminal is received after the encryption data, can be based on default solution corresponding with the predetermined encryption side Close mode, is decrypted to encryption data, obtains JSON data.Specifically, current time (unit can be obtained:Millisecond); Current time is taken the remainder to 10, the last two digits of current time are obtained, and using last two digits as key value;Carry Take each character in encryption data;Obtain the corresponding ASCII character of each character in encryption data;Will be every in encryption data The corresponding ASCII character of individual character all adds key value, and the new character of acquisition constitutes a character string, that is, obtain JSON data.
In embodiments of the present invention, JSON data can effectively ensure that in the transmission by self-defining encipher-decipher method Security.In specific implementation process, the data type information can be developer's typing, and the data type information is used In expression specified data type.
Step S102:Based on data type information, specified data type is determined, the specified data type is JSON data The type of the data object that needs are converted into.
As a kind of optional embodiment, before step S103, also include:Judge whether JSON data are sky, its In, JSON data are String types;If not it is empty, then remove the space in JSON data.
In specific implementation process, it can be determined that whether the character string in JSON data is empty, if sky is direct Return, be left intact, just this can further be processed if not empty, space that will be in character string removes Fall, specifically, space during trim () function can be called to remove character string.
In specific implementation process, the specified data type can be:String (character string) type, Integer is (whole Number) type, or Long (lint-long integer) type, or Float (floating number) type, or Objcet (object) type, etc..
For example, when whether judge class is same type with String, can by by the class of String and Class is carrying out contrasting judgement.Concrete decision procedure is class==String.class, if identical will be returned Hui Zhen, if not identical vacation will be returned.
For example, when whether judge class is same type with Integer, can be by by the class of Integer Carry out contrasting judgement with class.Concrete decision procedure is class==Integer.class, if identical will Return very, if not identical vacation will be returned.
For example, judging whether class is same type with Long, can be by by the class and class of Long To carry out contrasting judgement.Concrete decision procedure is class==Long.class, if identical will be returned very, such as Fruit is not that identical will return vacation.
For example, judging whether class is same type with Float, can by by the class of Float and Class is carrying out contrasting judgement.Concrete decision procedure is class==Float.class, if identical will be returned Very, vacation will be returned if not identical.
For example, the judgement of Objcet types is determined with certain otherness with above-mentioned, and Objcet types are in JOSN Storage is wrapped up with " { } ", if so a type is an Objcet type, then can be made whether so that " { " opens Head, if so that " { " beginning, we then determine that it is Objcet types.It is concrete to judge character string whether with " { " beginning By calling startsWith () function to be judged, if this function is returned very, explanation is Objcet classes to method Type, if it is not Objcet types that this function returns pseudoinstruction.
In embodiments of the present invention, it is intelligent that data are judged, go again to be adjusted according to different types manually without the need for artificial With different analysis modes, the workload of developer is reduced.
Step S103:JSON data are converted to into the data object of specified data type.
In specific implementation process, step S103 can be realized by the following manner:
(A) if specified data type is String types, because JSON data are exactly a String object, so this Place directly can be returned object.
(B) if specified data type is Integer types, Integer.valueOf (msg) functions are called by JSON numbers According to the data object for being converted into Integer types.So, exactly by msg (for representing JSON data) this String object It is converted to corresponding Integer objects.
(C) if specified data type is Long types, Long.valueOf (msg) functions are called by JSON data conversions Into the data object of Long types, wherein, msg is used to represent JSON data.So, just by this String objects conversion of msg Into corresponding Long objects.
(D) if specified data type is Float types, Float.valueOf (msg) functions are called to turn JSON data Change the data object of Float types into, wherein, msg is used to represent JSON data.So, just by msg, this String object turns Corresponding Float objects are changed into.
(E) if specified data type is Objcet types, JSON.parseObject (msg, clazz) function is called to incite somebody to action JSON data conversions into Objcet types data object, wherein, msg be used for represent JSON data.So, just by msg this String objects are converted to corresponding Objcet objects.
Step S104:Return the data object of the specified data type.
In specific implementation process, after the data object that JSON data are converted to specified data type, you can return The data object of the specified data type is to developer.
As a kind of optional embodiment, a function JSON2Object can be defined, this function encapsulates above-mentioned step The function of rapid S101~step S105.
Specifically, JSON2Object functions are defined as follows:
public static<T>T JSON2Object(String JSON,Class<T>class)
Next above-mentioned function is explained in detail:
<T>:General type type is represented, this is the characteristic that Java language is supported, this characteristic is called general type.General type It is a kind of characteristic of programming language.Allowing programmer to define some when strongly-typed program design language is called the turn and writes code can Become part, those parts are being indicated using front having to make as.Various program design languages make peace its compiler, running environment to general type Support it is different.By type parameterization with reach code reuse improve software development operating efficiency a kind of data type. General type class is reference type, is heap object, has been primarily introduced into type parameter this concept.Simply understand that general type is exactly one and moves State type, can return incoming type identical data type according to the incoming type of caller.
T:Represent that the data type for returning is exactly the general type type that we define.
JSON2Object:What is represented is function name
JSON:Represent the incoming JSON data for needing and parsing
Class<T>class:A class object is represented, this class object has individual feature, that is, the class object must be General type T type.It is follow-up corresponding general type object to be generated according to class objects in logic is processed.
In embodiments of the present invention, by using for general type this programme is turned the JSON data of String types Change arbitrary data object into.
In embodiments of the present invention, the resolving of JSON data is encapsulated, the durability of code is substantially increased.
Below, based on same inventive concept, a kind of device of parsing JSON data is present embodiments provided, as shown in Fig. 2 Including:
Acquiring unit 201, for obtaining JSON data and data type information corresponding with JSON data;
Determining unit 202, for based on data type information, determining specified data type, it is intended that data type is JSON data need the type of the data object being converted into;
Converting unit 203, for JSON data to be converted to the object of specified data type;
Returning unit 204, for returning the data object of specified data type.
As optional embodiment in, the specified data type, including:
Integer Integer types;Or
Lint-long integer Long types;Or
Floating number Float type;Or
Object Objcet types.
Used as optional embodiment in, the device of the parsing JSON data also includes:
Judging unit, for based on data type information, before determining specified data type, whether judging JSON data For sky, wherein, JSON data are String types;
Removal unit, for if not sky, then remove the space in JSON data.
As optional embodiment in, converting unit 204, including:
First conversion subunit, if being Integer types for specified data type, calls Integer.valueOf (msg) function by JSON data conversions into Integer types data object;Or
Second conversion subunit, if being Long types for specified data type, calls Long.valueOf (msg) letter Number by JSON data conversions into Long types data object;Or
3rd conversion subunit, if being Float types for specified data type, calls Float.valueOf (msg) Function by JSON data conversions into Float types data object;Or
4th conversion subunit, if being Objcet types for specified data type, calls JSON.parseObject (msg, clazz) function by JSON data conversions into Objcet types data object.
As optional embodiment in, acquiring unit 201, including:
Receiving subelement, for receiving encryption data, encryption data is encrypted using predetermined encryption mode;
Decryption subelement, for based on default manner of decryption corresponding with predetermined encryption side, being decrypted to encryption data, Obtain JSON data.
As optional embodiment in, predetermined encryption mode, specially:
Obtain current time;Current time is taken the remainder to 10, the last two digits of current time are obtained, and will be last Two digits are used as key value;Extract each character in JSON data;Each character obtained in JSON data is corresponding ASCII character;The corresponding ASCII character of each character in JSON data is deducted into key value, encryption data is obtained.
As optional embodiment in, subelement is decrypted, specifically for:
Obtain current time;Current time is taken the remainder to 10, the last two digits of current time are obtained, and will be last Two digits are used as key value;Extract each character in encryption data;Each character obtained in encryption data is corresponding ASCII character;The corresponding ASCII character of each character in encryption data is added into key value, JSON data are obtained.
As optional embodiment in, subelement is decrypted, specifically for:
System.currentTimeMillis () function is called to obtain the current time.
The device of the parsing JSON data introduced due to the present embodiment to implement the embodiment of the present application in parse JSON numbers According to the device that adopted of method, so the method based on the parsing JSON data described in the embodiment of the present application, this area Those of skill in the art will appreciate that the specific embodiment and its various change of the device of the parsing JSON data of the present embodiment Form, so how here realizes that the method in the embodiment of the present application is no longer situated between in detail for the device of parsing JSON data Continue.As long as those skilled in the art implement to parse the parsing JSON that the method for JSON data is adopted in the embodiment of the present application The device of data, belongs to the scope to be protected of the application.
Technical scheme in above-mentioned the embodiment of the present application, at least has the following technical effect that or advantage:
1st, in embodiments of the present invention, a kind of method of parsing JSON data is disclosed, is applied to parse JSON data In device, including:Obtain JSON data and data type information corresponding with the JSON data;Based on the data type Information, determines specified data type, and the specified data type is the data object that the JSON data needs are converted into Type;The JSON data are converted to into the data object of the specified data type.Due to automatically Json data turning Change any object data into, without the need for developer the process that JSON is changed oneself is realized again, reduce the probability for parsing mistake occur. In so as to solve prior art JSON data are parsed by the way of artificial, there is the skill for parsing mistake easily occur Art problem.Realizing reduces the probability of parsing JSON data appearance parsing mistakes, and calls simple, easy to use technology effect Really.
2nd, in embodiments of the present invention, this programme is enabled by the JSON data of String types by using for general type It is converted into any type of data object.
3rd, in embodiments of the present invention, the resolving of JSON data is encapsulated, the durability of code is substantially increased.
4th, in embodiments of the present invention, it is intelligent that data are judged, without the need for artificially going again according to different types manually Different analysis modes are called, the workload of developer is reduced.
5th, in embodiments of the present invention, by self-defining encipher-decipher method, can effectively ensure that JSON data are being passed Security in defeated.
Those skilled in the art are it should be appreciated that embodiments of the invention can be provided as method, system or computer program Product.Therefore, the present invention can be using complete hardware embodiment, complete software embodiment or with reference to the reality in terms of software and hardware Apply the form of example.And, the present invention can be adopted and wherein include the computer of computer usable program code at one or more The computer program implemented in usable storage medium (including but not limited to magnetic disc store, CD-ROM, optical memory etc.) is produced The form of product.
The present invention is the flow process with reference to method according to embodiments of the present invention, equipment (system) and computer program Figure and/or block diagram are describing.It should be understood that can be by computer program instructions flowchart and/or each stream in block diagram The combination of journey and/or square frame and flow chart and/or the flow process in block diagram and/or square frame.These computer programs can be provided The processor of all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce A raw machine so that produced for reality by the instruction of computer or the computing device of other programmable data processing devices The device of the function of specifying in present one flow process of flow chart or one square frame of multiple flow processs and/or block diagram or multiple square frames.
These computer program instructions may be alternatively stored in can guide computer or other programmable data processing devices with spy In determining the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory is produced to be included referring to Make the manufacture of device, the command device realize in one flow process of flow chart or one square frame of multiple flow processs and/or block diagram or The function of specifying in multiple square frames.
These computer program instructions also can be loaded in computer or other programmable data processing devices so that in meter Series of operation steps is performed on calculation machine or other programmable devices to produce computer implemented process, so as in computer or The instruction performed on other programmable devices is provided for realizing in one flow process of flow chart or multiple flow processs and/or block diagram one The step of function of specifying in individual square frame or multiple square frames.
, but those skilled in the art once know basic creation although preferred embodiments of the present invention have been described Property concept, then can make other change and modification to these embodiments.So, claims are intended to be construed to include excellent Select embodiment and fall into having altered and changing for the scope of the invention.
Obviously, those skilled in the art can carry out the essence of various changes and modification without deviating from the present invention to the present invention God and scope.So, if these modifications of the present invention and modification belong to the scope of the claims in the present invention and its equivalent technologies Within, then the present invention is also intended to comprising these changes and modification.

Claims (10)

1. a kind of method of parsing JSON data, it is characterised in that in being applied to the device for parsing JSON data, the parsing The method of JSON data, including:
Obtain JSON data and the corresponding data type information of the JSON data;
Based on the data type information, specified data type is determined, the specified data type is the JSON data and needs The type of the data object to be converted into;
The JSON data are converted to into the data object of the specified data type;
Return the data object of the specified data type.
2. the method for parsing JSON data as claimed in claim 1, it is characterised in that the specified data type, including:
Integer Integer types;Or
Lint-long integer Long types;Or
Floating number Float type;Or
Object Objcet types.
3. the method for parsing JSON data as claimed in claim 1, it is characterised in that believed based on the data type described Breath, before determining specified data type, also includes:
Judge whether the JSON data are empty, wherein, the JSON data are String types;
If not it is empty, then remove the space in the JSON data.
4. the method for parsing JSON data as claimed in claim 1, it is characterised in that described to be converted to the JSON data The data object of the specified data type, including:
If the specified data type is Integer types, Integer.valueOf (msg) functions are called by the JSON Data object of the data conversion into Integer types;Or
If the specified data type is Long types, Long.valueOf (msg) functions are called to turn the JSON data Change the data object of Long types into;Or
If the specified data type is Float types, Float.valueOf (msg) functions are called by the JSON data It is converted into the data object of Float types;Or
If the specified data type is Objcet types, JSON.parseObject (msg, clazz) functions are called by institute JSON data conversions are stated into the data object of Objcet types.
5. the method for the parsing JSON data as described in Claims 1 to 4 is arbitrary, it is characterised in that the acquisition JSON data, Including:
Encryption data is received, the encryption data is encrypted using predetermined encryption mode;
Based on default manner of decryption corresponding with the predetermined encryption side, the encryption data is decrypted, obtains described JSON data.
6. the method for parsing JSON data as claimed in claim 5, it is characterised in that the predetermined encryption mode, specially:
Obtain current time;
The current time is taken the remainder to 10, the last two digits of the current time are obtained, and by described last two Numeral is used as key value;
Extract each character in the JSON data;
Obtain the corresponding ASCII character of each character in the JSON data;
The corresponding ASCII character of each character in the JSON data is deducted into the key value, the encryption data is obtained.
7. the method for parsing JSON data as claimed in claim 5, it is characterised in that it is described based on the predetermined encryption side Corresponding default manner of decryption, is decrypted to the encryption data, obtains the JSON data, including:
Obtain current time;
The current time is taken the remainder to 10, the last two digits of the current time are obtained, and by described last two Numeral is used as key value;
Extract each character in the encryption data;
Obtain the corresponding ASCII character of each character in the encryption data;
The corresponding ASCII character of each character in the encryption data is added into the key value, the JSON data are obtained.
8. the method for parsing JSON data as claimed in claims 6 or 7, it is characterised in that the acquisition current time, bag Include:
System.currentTimeMillis () function is called to obtain the current time.
9. a kind of device of parsing JSON data, it is characterised in that include:
Acquiring unit, for obtaining JSON data and data type information corresponding with the JSON data;
Determining unit, for based on the data type information, determining specified data type, the specified data type is institute State the type of the data object that JSON data need to be converted into;
Converting unit, for the JSON data to be converted to the object of the specified data type;
Returning unit, for returning the data object of the specified data type.
10. the device of JSON data is parsed as claimed in claim 9, it is characterised in that the specified data type, including:
Integer Integer types;Or
Lint-long integer Long types;Or
Floating number Float type;Or
Object Objcet types.
CN201611121521.8A 2016-12-08 2016-12-08 JSON data analysis method and device Pending CN106649634A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611121521.8A CN106649634A (en) 2016-12-08 2016-12-08 JSON data analysis method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611121521.8A CN106649634A (en) 2016-12-08 2016-12-08 JSON data analysis method and device

Publications (1)

Publication Number Publication Date
CN106649634A true CN106649634A (en) 2017-05-10

Family

ID=58820152

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611121521.8A Pending CN106649634A (en) 2016-12-08 2016-12-08 JSON data analysis method and device

Country Status (1)

Country Link
CN (1) CN106649634A (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107943483A (en) * 2017-11-23 2018-04-20 北京酷我科技有限公司 A kind of data resolution method in iOS
CN108170652A (en) * 2017-12-29 2018-06-15 北京酷我科技有限公司 A kind of method of iOS dictionaries security solution
CN108932128A (en) * 2018-07-03 2018-12-04 武汉斗鱼网络科技有限公司 A kind of conversion method of message format, device, storage medium and android terminal
CN109656550A (en) * 2018-12-14 2019-04-19 平安城市建设科技(深圳)有限公司 Json data analysis method, device, equipment and readable storage medium storing program for executing
CN109684607A (en) * 2017-10-19 2019-04-26 腾讯科技(深圳)有限公司 JSON data analysis method, device, computer equipment and storage medium
CN110019032A (en) * 2017-09-20 2019-07-16 北京国双科技有限公司 A kind of data processing method and its relevant apparatus
CN110222008A (en) * 2019-05-06 2019-09-10 平安国际智慧城市科技股份有限公司 A kind of conversion method of data format, system, medium and electronic equipment
CN111680475A (en) * 2020-04-28 2020-09-18 五八有限公司 Data conversion method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105159928A (en) * 2015-08-05 2015-12-16 深圳联友科技有限公司 Method and system for converting JSON data into model data
US20160092036A1 (en) * 2014-09-26 2016-03-31 Oracle International Corporation Recasting a form-based user interface into a mobile device user interface using common data
CN105868050A (en) * 2015-12-29 2016-08-17 乐视网信息技术(北京)股份有限公司 Verification method and device based on JSON data

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160092036A1 (en) * 2014-09-26 2016-03-31 Oracle International Corporation Recasting a form-based user interface into a mobile device user interface using common data
CN105159928A (en) * 2015-08-05 2015-12-16 深圳联友科技有限公司 Method and system for converting JSON data into model data
CN105868050A (en) * 2015-12-29 2016-08-17 乐视网信息技术(北京)股份有限公司 Verification method and device based on JSON data

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110019032A (en) * 2017-09-20 2019-07-16 北京国双科技有限公司 A kind of data processing method and its relevant apparatus
CN109684607A (en) * 2017-10-19 2019-04-26 腾讯科技(深圳)有限公司 JSON data analysis method, device, computer equipment and storage medium
CN107943483A (en) * 2017-11-23 2018-04-20 北京酷我科技有限公司 A kind of data resolution method in iOS
CN107943483B (en) * 2017-11-23 2023-03-24 北京酷我科技有限公司 Data forward analysis method in iOS
CN108170652A (en) * 2017-12-29 2018-06-15 北京酷我科技有限公司 A kind of method of iOS dictionaries security solution
CN108932128A (en) * 2018-07-03 2018-12-04 武汉斗鱼网络科技有限公司 A kind of conversion method of message format, device, storage medium and android terminal
CN109656550A (en) * 2018-12-14 2019-04-19 平安城市建设科技(深圳)有限公司 Json data analysis method, device, equipment and readable storage medium storing program for executing
CN110222008A (en) * 2019-05-06 2019-09-10 平安国际智慧城市科技股份有限公司 A kind of conversion method of data format, system, medium and electronic equipment
CN111680475A (en) * 2020-04-28 2020-09-18 五八有限公司 Data conversion method and device, electronic equipment and storage medium
CN111680475B (en) * 2020-04-28 2022-11-15 五八有限公司 Data conversion method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN106649634A (en) JSON data analysis method and device
CN106970820B (en) Code storage method and code storage device
CN103684760B (en) The encryption of communication and the method, apparatus of decryption and system
WO2018210096A1 (en) Rule engine-based rule configuration method, terminal and device, and storage medium
CN110933063B (en) Data encryption method, data decryption method and equipment
CN107566090B (en) Fixed-length/variable-length text message processing method and device
CN109255209A (en) A kind of data processing method, device, equipment and storage medium
CN110009336A (en) Evidence collecting method and device based on block chain
CN114238948A (en) Application program detection method and device, electronic equipment and storage medium
CN105183466A (en) Encapsulating method for simplifying echarts invocation
CN112214653A (en) Character string recognition method and device, storage medium and electronic equipment
CN114462356A (en) Text error correction method, text error correction device, electronic equipment and medium
CN109658545A (en) A kind of cipher set-up method and network access system of network lock
CN115145574A (en) Code generation method and device, storage medium and server
CN101546272A (en) Compiler and realizing method thereof
CN113780847A (en) Intelligent community information processing method based on Internet of things and server
CN108153745B (en) Application data calling method and application development system
Scanzio et al. QRscript: Embedding a Programming Language in QR codes to support Decision and Management
US10115374B2 (en) Variable glyph encoding
CN111260080A (en) Process optimization method, device, terminal and storage medium based on machine learning
CN108845794B (en) Streaming operation system, method, readable medium and storage controller
CN106034119A (en) Encryption mixing method and device for application installation package
CN108734149B (en) Text data scanning method and device
CN111753494A (en) Woff font decryption method and system based on selenium
CN113742294A (en) Method, system, device and medium for decoding ASN.1-PER signaling message

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20170510