CN109005469A - A kind of conversion method of message format, device, storage medium and android terminal - Google Patents
A kind of conversion method of message format, device, storage medium and android terminal Download PDFInfo
- Publication number
- CN109005469A CN109005469A CN201810718902.7A CN201810718902A CN109005469A CN 109005469 A CN109005469 A CN 109005469A CN 201810718902 A CN201810718902 A CN 201810718902A CN 109005469 A CN109005469 A CN 109005469A
- Authority
- CN
- China
- Prior art keywords
- key
- character
- information
- jsonstr
- format
- 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.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/47—End-user applications
- H04N21/488—Data services, e.g. news ticker
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/43—Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
- H04N21/435—Processing of additional data, e.g. decrypting of additional data, reconstructing software from modules extracted from the transport stream
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N21/00—Selective content distribution, e.g. interactive television or video on demand [VOD]
- H04N21/40—Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
- H04N21/47—End-user applications
- H04N21/478—Supplemental services, e.g. displaying phone caller identification, shopping application
- H04N21/4788—Supplemental services, e.g. displaying phone caller identification, shopping application communicating with other users, e.g. chatting
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- General Engineering & Computer Science (AREA)
- Information Transfer Between Computers (AREA)
- User Interface Of Digital Computer (AREA)
Abstract
The embodiment of the invention discloses a kind of conversion method of message format, device, storage medium and android terminals.This method comprises: verifying when getting Json data to jsonStr, and in checking procedure, at least one key-value pair information is obtained;At least one described key-value pair information is spliced according to barrage message format, obtains barrage message format.It by using technical solution provided herein, may be implemented to be converted into the format of Json format barrage message format, realize the effect quickly shown to the data of the Json format received with barrage message.
Description
Technical field
The present embodiments relate to Android technical field more particularly to a kind of conversion methods of message format, device, storage
Medium and android terminal.
Background technique
Current internet rapid development, the changes in demand of the network user was not only fast but also big, the transmission and conversion of data-message
Efficiency has become one of the problem of relatively paying close attention in field.
Currently, data transmission is usually Json format, the parsing of the data of Json format is usually to parse in traditional scheme
At an object, and the data of Json format can not be transformed into an another type of data, or specific barrage association
View.And interest institute when barrage message is broadcast live as current user viewing Online Video, online and other video type programs
So how to realize the technical problem for converting in parsing and having become technical staff and being badly in need of breakthrough.
Summary of the invention
The embodiment of the present invention provides conversion method, device, storage medium and the android terminal of a kind of message format, Ke Yishi
Barrage message format now is converted into the format of Json format, realizes the data to the Json format received quickly with barrage
The effect that message is shown.
In a first aspect, the embodiment of the invention provides a kind of conversion methods of message format, this method comprises:
When getting Json data, jsonStr is verified, and in checking procedure, obtains at least one key-value pair
Information;
At least one described key-value pair information is spliced according to barrage message format, obtains barrage message format.
Further, described jsonStr to be verified, and in checking procedure when getting Json data, it obtains extremely
A few key-value pair information, comprising:
When getting Json data, by retrieving respectively to jsonStr head and the tail character, and whether the head and the tail character is determined
For the first Json format standard character;
If so, verifying successfully, it is assigned to jsonStr by the head and the tail character deletion, and by the character string after deletion, is obtained
JsonStr after to assignment;
According to other Json format standard characters in addition to the first Json format standard character, after the assignment
JsonStr be split processing, obtain at least one key-value pair information.
Further, other Json format standard words of the basis in addition to the first Json format standard character
Symbol, is split processing to the jsonStr after the assignment, obtains at least one key-value pair information, comprising:
According to the 2nd Json format standard character, processing is split to the jsonStr after the assignment, obtains character string
Array;
According to the 3rd Json format standard character, processing is split to all character string dimensions, by each word
Symbol goes here and there and is stored in template array tmpArray2 [0] after array information is divided, and in tmpArray2 [1], obtains at least one key assignments
To information.
Further, according to the 3rd Json format standard character, place is split to all character string dimensions
Reason will be stored at least one template array tmpArray2 [0], tmpArray2 [1] after the segmentation of each character string dimension information
In after, the method also includes:
Calling TextUtils.equals (tmpArray is passed through to tmpArray2 [0] data of each template array
2 [0], " ") method judges whether tmpArray2 [0] data are empty;
If so, returning to jsonStr verifies failure information;
If not, it is determined that the jsonStr is verified successfully.
Further, at least one described key-value pair information is spliced according to barrage message format, obtains barrage and disappears
Cease format, comprising:
All key-value pair informations are stored in the map object constructed in advance;
The key letter that obtains the key information in map object by calling entry.getKey () method, and will acquire
Breath is converted into the variable of the String type an of key information;And it is obtained by calling entry.getValue () method
Value information in map object, and the value information that will acquire is converted into the variable of the String type an of value information;
By calling stringBuilde to the variable of the String type of key information and the String type of value information
Variable spliced according to default barrage message format, obtain barrage message format.
Further, described by calling stringBuilde to the variable and value information of the String type of key information
The variable of String type spliced according to default barrage message format, obtain barrage message format, comprising:
By calling stringBuilde to the variable of the String type of all key informations and value information
The first barrage format standard character is added between the variable of String type, forms at least one barrage message key-value pair information;
Second barrage format standard character added to last position of each barrage message key-value pair information, and by institute
Some barrage message key-value pair informations are combined into a result character string;
The the second barrage format standard character for deleting last of the result character string, obtains barrage message format.
Second aspect, the embodiment of the invention also provides a kind of conversion equipment of message format, which includes:
Key-value pair information obtains module and verifies when for getting Json data to jsonStr, and is verifying
Cheng Zhong obtains at least one key-value pair information;
Barrage message format splicing module, for carrying out at least one described key-value pair information according to barrage message format
Splicing, obtains barrage message format.
Further, the barrage message format splicing module, comprising:
The first character check unit, when for getting Json data, by being retrieved respectively to jsonStr head and the tail character,
And determine whether the head and the tail character is the first Json format standard character;
The first character deletion unit is used for if so, verify successfully, by the head and the tail character deletion, and will be after deletion
Character string is assigned to jsonStr, the jsonStr after obtaining assignment;
Key-value pair information acquiring unit, for according to other Json lattice in addition to the first Json format standard character
Formula standard character is split processing to the jsonStr after the assignment, obtains at least one key-value pair information.
The third aspect, the embodiment of the present application provide a kind of computer readable storage medium, are stored thereon with computer journey
Sequence realizes the conversion method of the message format as described in the embodiment of the present application when the program is executed by processor.
Fourth aspect, the embodiment of the present application provide a kind of android terminal, including memory, processor and are stored in storage
It can realize on device and when the computer program of processor operation, the processor execute the computer program as the application is real
Apply the conversion method of message format described in example.
Technical solution provided by the embodiment of the present application verifies jsonStr when by getting Json data,
And in checking procedure, at least one key-value pair information is obtained;By at least one described key-value pair information according to barrage message lattice
Formula is spliced, and barrage message format is obtained.By using technical solution provided herein, may be implemented to Json format
Format be converted into barrage message format, realization shows the data of the Json format received quickly with barrage message
Effect.
Detailed description of the invention
Fig. 1 is the flow chart of the conversion method for the message format that the embodiment of the present invention one provides;
Fig. 2 is the structural schematic diagram of the conversion equipment for the message format that the embodiment of the present invention three provides;
Fig. 3 is a kind of structural schematic diagram of android terminal provided by the embodiments of the present application.
Specific embodiment
The present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched
The specific embodiment stated is used only for explaining the present invention rather than limiting the invention.It also should be noted that in order to just
Only the parts related to the present invention are shown in description, attached drawing rather than entire infrastructure.
It should be mentioned that some exemplary embodiments are described as before exemplary embodiment is discussed in greater detail
The processing or method described as flow chart.Although each step is described as the processing of sequence by flow chart, many of these
Step can be implemented concurrently, concomitantly or simultaneously.In addition, the sequence of each step can be rearranged.When its operation
The processing can be terminated when completion, it is also possible to have the additional step being not included in attached drawing.The processing can be with
Corresponding to method, function, regulation, subroutine, subprogram etc..
Embodiment one
Fig. 1 is the flow chart of the conversion method for the message format that the embodiment of the present invention one provides, and the present embodiment is applicable to disappear
The case where ceasing format conversion, the conversion equipment of this method message format provided by the embodiment of the present invention execute, should
Device can be realized by the mode of software and/or hardware, and can be integrated in android terminal.
As shown in Figure 1, the conversion method of the message format includes:
S110, when getting Json data, jsonStr is verified, and in checking procedure, obtains at least one key
Value is to information.
Wherein it is possible to get Json data by way of network connection, after getting Json data, need pair
JsonStr is verified, the benefit being arranged in this way be if finding that the Json data received are illegal in checking procedure, can
It is translated into barrage message format with direct cancellation, conversion fault will be redefined by avoiding making a fault in the conversion process also
The reason of whether be caused by Json data are illegal.
Because carrying out information storage in Json data at least one key-value pair information, illustratively,
JsonStr={ " name ": " zhangsan ", " age ": " 20 ", " height ": " 180 ", " sex ": " male " }, wherein name
Be exactly a key-value pair information with zhangsan, age and 20 is another key-value pair information, similarly, height and 180 and
Sex and male is a key-value pair information.In checking procedure, at least one key-value pair information is obtained, that is, obtain and work as
All key-value pair informations in preceding Json data.Wherein acquisition modes can be is removed in jsonStr by corresponding method
Some specific symbols, such as " { } " and ": " etc..
S120, at least one described key-value pair information is spliced according to barrage message format, obtains barrage message lattice
Formula.
Wherein, barrage message format can be obtained ahead of time can be used to do the format of barrage message display, such as
Some specific identifiers are added between key-value pair information, illustratively, the format of a barrage message is as follows: name@=
Zhangsan/age=20/height=180/sex=male, it is recognised that being needed between each key-value pair wherein
It is inserted into "@=" character, and needs to be inserted into "/" character between each key-value pair.It is can be obtained by this way comprising Json data
Whole key-value pair informations barrage message content.
Technical solution provided by the embodiment of the present application verifies jsonStr when by getting Json data,
And in checking procedure, at least one key-value pair information is obtained;By at least one described key-value pair information according to barrage message lattice
Formula is spliced, and barrage message format is obtained.By using technical solution provided herein, may be implemented to Json format
Format be converted into barrage message format, realization shows the data of the Json format received quickly with barrage message
Effect.
It is based on the above technical solution, optionally, described jsonStr to be verified when getting Json data,
And in checking procedure, at least one key-value pair information is obtained, comprising: when getting Json data, by jsonStr head and the tail
Character is retrieved respectively, and determines whether the head and the tail character is the first Json format standard character;If so, verify successfully, it will
The head and the tail character deletion, and the character string after deletion is assigned to jsonStr, the jsonStr after obtaining assignment;According to except institute
Other Json format standard characters other than the first Json format standard character are stated, the jsonStr after the assignment is divided
Processing is cut, at least one key-value pair information is obtained.
Wherein, the first Json format standard character can be primarily determine whether be Json data character, such as can be with
It is jsonStr head and the tail character " { } ", and other Json format standard words in addition to the first Json format standard character
Symbol, can be quotation marks, comma and colon etc., other any characters other than key-value pair information.The present embodiment by pair
First Json format standard character and other Json format standard characters, which are classified, not to be verified, if verification goes wrong,
It is illegal directly to return to current Json data, and will after the first Json format standard character is verified and deleted
As a result it is assigned to jsonStr, in this way during programming, jsonStr can be handled in sequence, will not be gone out
The excessive problem of existing intermediate variable.
Based on the above technical solution, optionally, the basis is in addition to the first Json format standard character
Other Json format standard characters, processing is split to the jsonStr after the assignment, obtain at least one key-value pair letter
Breath, comprising: according to the 2nd Json format standard character, processing is split to the jsonStr after the assignment, obtains character string
Array;According to the 3rd Json format standard character, processing is split to all character string dimensions, by each character string
Template array tmpArray2 [0] is stored in after array information segmentation, in tmpArray2 [1], obtains at least one key-value pair letter
Breath.By the way that the key-value pair information gradually parsed to be stored in template array, two of template array deposit the technical program
Storage space is set stores key information and value information respectively, thereby realizes the mesh parsed while verification to Json data
, the processing speed of data is improved, the process flow of data is simplified.
Based on the above technical solution, optionally, according to the 3rd Json format standard character, to all words
Symbol string array is split processing, will be stored at least one template array after the segmentation of each character string dimension information
After in tmpArray2 [0], tmpArray2 [1], the method also includes: to the tmpArray2 of each template array
[0] data are by calling whether TextUtils.equals (tmpArray 2 [0], " ") method judges tmpArray2 [0] data
For sky;If so, returning to jsonStr verifies failure information;If not, it is determined that the jsonStr is verified successfully.Wherein, exist
In Json data, what the key information in each key-value pair information was necessarily present, if there is no then illustrating current Json data
It is illegal.So whether the inspection by this scheme that the Json data currently verified can be determined more accurately is legal, improve
Accuracy during data check.
Based on the above technical solution, optionally, by least one described key-value pair information according to barrage message lattice
Formula is spliced, and barrage message format is obtained, comprising: stores all key-value pair informations in the map object constructed in advance;Pass through
The entry.getKey () method of calling is converted into one come the key information that obtains the key information in map object, and will acquire
The variable of the String type of key information;And it is obtained in map object by calling entry.getValue () method
Value information, and the value information that will acquire is converted into the variable of the String type an of value information;Pass through calling
StringBuilde is to the variable of the variable of the String type of key information and the String type of value information according to default bullet
Curtain message format is spliced, and barrage message format is obtained.In the present solution, giving one kind passes through getKey in Map object
Function and getValue function obtain the key information and value information that pre-deposit in Map object in key-value pair information, and respectively
It is converted into the variable of the variable of the String type of key information and the String type of value information, then passes through stringBuilde pairs
It is spliced, and barrage message format is obtained, and the benefit being arranged in this way is the attribute logarithm that can remove key information and value information
According to influencing caused by splicing, is all handled, be advantageously implemented to barrage message format with the variable of String type
Conversion.
Based on the above technical solution, optionally, described by calling stringBuilde to key information
The variable of the String type of the variable and value information of String type is spliced according to default barrage message format, is obtained
Barrage message format, comprising: by calling stringBuilde to the variable of the String type of all key informations and
The first barrage format standard character is added between the variable of the String type of value information, forms at least one barrage message key assignments
To information;Second barrage format standard character added to last position of each barrage message key-value pair information, and by institute
Some barrage message key-value pair informations are combined into a result character string;Delete last the second of the result character string
Barrage format standard character, obtains barrage message format.Wherein, by calling stringBuilde to realize in key-value pair information
Key information and value information between the first barrage format standard character be added, and last position of key-value pair information is added
Add the second barrage format standard character, after removing the second barrage format standard character of entire the last one position of character string,
The data of barrage message format can be formed, to carry out the displaying of barrage message.
Embodiment two
The preferred embodiment that the present embodiment provides on the basis of the above embodiments, in order to allow those skilled in the art
The understanding being more clear technical solution provided herein, this preferred embodiment are as follows:
The data of Json format can be quickly transformed into the protocol data of barrage format by the implementation of this programme, and
And the conversion process can be realized parsing and conversion is carried out simultaneously to achieve the purpose that improve transfer efficiency.
This programme will be unfolded and be illustrated mainly around following several aspects
One, the verification of Json data.
Two, the flow path switch of data.
Next the implementation method and implementing procedure of above-mentioned steps be will be described in:
One, the verification of Json data
This step mainly describes the method for calibration of Json data, can effectively verify Json number by the implementation of this step
It is only that legal Json data are just converted according to whether being legal, it, in this way can in advance will be non-otherwise without conversion
Method data carry out shielding to improve the efficiency of conversion.
In order to which the verification for carrying out legitimacy to Json data gives an exemplary Json data jsonStr to say first
Bright and judgment method, jsonStr=" name ": " zhangsan ", " age ": " 20 ", " height ": " 180 ", " sex ": "
Male " }, dissection process next will be carried out regarding to the issue above.
Determine to sentence by calling the tool method TextUtils.isEmpty (jsonStr) in TextUtils class first
As soon as determining jsonStr is a null character string, indicate it is that directly verification terminates null character string at this time if returning to true,
Json data are illegal, otherwise begin to real checking process.
First character firstChar is obtained by jsonStr.charAt (0) first, passes through calling
JsonStr.charAt (jsonStr.length-1) obtains last character lastChar, then passes through calling
FirstChar.equals (" { ") method determine first character be " ", if not directly passing through calling return
False indicates that verification failure connects if the firstChar determined by queals method is " { " and lastChar be " } "
Carry out next step judgement.
By calling character truncation that function substring is taken to get rid of the first character in jsonStr, specifically
Removing method is by calling jsonStr=jsonStr.substring (1, jsonStr.length-1) to remove head to intercept
Position head and the tail bracket character string, the character string after interception is assigned to jsonStr by us again, and such jsonStr is just without head
The bracket character of position head and the tail.
Next processing is being split to jsonStr character string by calling character string segmentation function, it is specifically logical
Calling jsonStr.split (", ") method is crossed to be realized.Return after segmentation is a character string dimension, is passed through
String [] tmpArray is defined receive and return the result.If function segmentation failure, just by calling return
False indicates verification failure, otherwise continues following verifying works.
Successively take out tmpArray array in element and by the element carry out again call split (": ") function come into
Row dividing processing, if there is any one segmentation failure just direct return false indicate verify right.If segmentation is normal
In the result divided every time, we are labeled as tmpArray2.
Remove first character therein followed by acquisition tmpArray2 [0] and passes through calling
TextUtils.equals (tmpArray 2 [0], " ") method come judge tmpArray2 [0] its value whether be it is empty, if it is sky
Just by calling return false to indicate verification failure.Indicate that the json is if above-mentioned all conditions complete verification passes through
One correct json data information.
Why take out the reason of the value of tmpArray2 [0] is verified be the value is key in key-value pair in json
Information, if key be it is empty so this be illegal in the regulation of key-value pair, therefore be exactly an illegal json data, institute
To need to carry out key decision logic one by one.
Two, the flow path switch of data.
This step mainly describes Json data are how to be converted into the data of a barrage format.For convenience hereafter
Understand that we provide the form type of the data of barrage first, it is specific as follows shown;
Name@=zhangsan/age@=20/height@=180/sex@=male
Next we will be described in how specific flow path switch is implemented.
It can be parsed out multiple key-value pair informations in json character string by the abovementioned steps in step 1, this
When we need to construct a Map object, specific construction method is by calling Map<String, String>mMap=new
HashMap<String, String>() method construct a mMap object, and the key in mMap object is one
The data of String type, value are also the data of a String type.
Next, by calling mMap.put (tmpArray2 [0], tmpArray2 [1]) function in mMap that will parse
Key-value pair information out is stored into a mMap object, and it is more that above-mentioned steps carry out meeting in training in rotation decision process to tmpArray
Secondary calling mMap.put (tmpArray2 [0], tmpArray2 [1]) function, after so complete all tmpArray arrays of poll
Key-value pair information all in jsonStr is just stored in mMap object at this time.
Next, needing to construct the class of a StringBuilder type, such is for doing string-concatenation operation
, specific construction method is by calling StringBuilder stringBuilder=newStringBuilder ();
Training in rotation is carried out to mMap object by Iterator first, by can all there is a calling during each training in rotation
The temporary variable of iter, we return to the object of a Map.Entry by calling the next method in iter, specifically logical
Cross calling Map.Entry entry=(Map.Entry) iter.next ();Method come realize to.
Next we need to obtain the key information in map object by calling entry.getKey () method, and
The key information forced type that will acquire is converted into the variable of a String type, particular by (String)
Come what is realized, the result that will acquire is received entry.getKey () mode with the variable key of a String type.
The value that obtains the value information in map object by calling entry.getValue () method, and will acquire
Information forced type is converted into the variable of a String type, particular by the side (String) entry.getValue ()
Come what is realized, the result that will acquire is received formula with the variable value of a String type.
Then, then by calling stringBuilder.append (key) the .append ("@in stringBuilder
=") mode of .append (value) adds a data, what wherein append method indicated is in stringBuilder
One character string of middle addition.
Upper above-mentioned key-value pair information is all added during each training in rotation of mMap object, and is terminated in each training in rotation
When call stringBuilder.append ("/") method to add an end mark by investigation.In this way when entire wheel
Instruction data all when completion are stored in stringBuilder and suffer.
It is obtained most followed by the stringBuilder.toString method called in stringBuilder object
A whole String type exclusively enjoys tmpResultStr.By above-mentioned analysis it is recognised that meeting in above-mentioned generating process
It adds a "/" separator more last position, then needs at this time by calling in tmpResultStr
TmpResultStr.substring (0, tmpResultStr.length-1) removes last character, the word after interception
Symbol is labeled as resultStr, and resultStr is exactly the specifying information content of required barrage agreement at this time.
This programme can not propose the data that the data sequence of Json format is melted into barrage message format in traditional scheme
The algorithm design of a set of completely new parsing and serializing is gone out, and has been to convert while parsing rather than parsed completely
It is converted again, thus can transfer efficiency be remarkably enhanced.
Embodiment three
Fig. 2 is the structural schematic diagram of the conversion equipment for the message format that the embodiment of the present invention three provides.As shown in Fig. 2, institute
State the conversion equipment of message format, comprising:
Key-value pair information obtains module 210 and verifies when for getting Json data to jsonStr, and is verifying
In the process, at least one key-value pair information is obtained;
Barrage message format splicing module 220, at least one key-value pair information by described according to barrage message format
Spliced, obtains barrage message format.
Technical solution provided by the embodiment of the present application verifies jsonStr when by getting Json data,
And in checking procedure, at least one key-value pair information is obtained;By at least one described key-value pair information according to barrage message lattice
Formula is spliced, and barrage message format is obtained.By using technical solution provided herein, may be implemented to Json format
Format be converted into barrage message format, realization shows the data of the Json format received quickly with barrage message
Effect.
On the basis of the various embodiments described above, the barrage message format splicing module, comprising: the first character check list
Whether member when for getting Json data, by retrieving respectively to jsonStr head and the tail character, and determines the head and the tail character
For the first Json format standard character;The first character deletion unit is used to delete the head and the tail character if so, verify successfully
It removes, and the character string after deletion is assigned to jsonStr, the jsonStr after obtaining assignment;Key-value pair information acquiring unit is used
In other Json format standard characters of basis in addition to the first Json format standard character, after the assignment
JsonStr is split processing, obtains at least one key-value pair information.
Method provided by any embodiment of the invention can be performed in the said goods, has the corresponding functional module of execution method
And beneficial effect.
Example IV
The embodiment of the present application also provides a kind of storage medium comprising computer executable instructions, and the computer is executable
It instructs when being executed by computer processor for executing a kind of conversion method of message format, this method comprises:
When getting Json data, jsonStr is verified, and in checking procedure, obtains at least one key-value pair
Information;
At least one described key-value pair information is spliced according to barrage message format, obtains barrage message format.
Storage medium --- any various types of memory devices or storage equipment.Term " storage medium " is intended to wrap
It includes: install medium, such as CD-ROM, floppy disk or magnetic tape equipment;Computer system memory or random access memory, such as
DRAM, DDR RAM, SRAM, EDO RAM, blue Bath (Rambus) RAM etc.;Nonvolatile memory, such as flash memory, magnetic medium
(such as hard disk or optical storage);Register or the memory component of other similar types etc..Storage medium can further include other
Memory of type or combinations thereof.In addition, storage medium can be located at program in the computer system being wherein performed, or
It can be located in different second computer systems, second computer system is connected to computer by network (such as internet)
System.Second computer system can provide program instruction to computer for executing.Term " storage medium " may include can
To reside in different location two or more storage mediums of (such as in the different computer systems by network connection).
Storage medium can store the program instruction (such as being implemented as computer program) that can be performed by one or more processors.
Certainly, a kind of storage medium comprising computer executable instructions, computer provided by the embodiment of the present application
The conversion operation for the message format that executable instruction is not limited to the described above can also be performed the application any embodiment and be provided
Message format conversion method in relevant operation.
Embodiment five
The embodiment of the present application provides a kind of android terminal, and provided by the embodiments of the present application disappear can be integrated in the android terminal
Cease the conversion equipment of format.Fig. 3 is a kind of structural schematic diagram of android terminal provided by the embodiments of the present application.As shown in figure 3, should
Android terminal may include: that memory 301, central processing unit (Central Processing Unit, CPU) 302 (are also known as located
Manage device, hereinafter referred to as CPU), circuit board (not shown) and power circuit (not shown).The circuit board is placed in institute
State the space interior that shell surrounds;The CPU302 and the memory 301 are arranged on the circuit board;The power supply electricity
Road, for each circuit or the device power supply for the android terminal;The memory 301, for storing executable program generation
Code;The CPU302 is run and the executable journey by reading the executable program code stored in the memory 301
The corresponding computer program of sequence code, to perform the steps of
When getting Json data, jsonStr is verified, and in checking procedure, obtains at least one key-value pair
Information;
At least one described key-value pair information is spliced according to barrage message format, obtains barrage message format.
The android terminal further include: Peripheral Interface 303, RF (Radio Frequency, radio frequency) circuit 305, audio-frequency electric
Road 306, loudspeaker 311, power management chip 308, input/output (I/O) subsystem 309, touch screen 312, other input/controls
Control equipment 310 and outside port 304, these components are communicated by one or more communication bus or signal wire 307.
It should be understood that illustrating the example that android terminal 300 is only android terminal, and android terminal 300
It can have than shown in the drawings more or less component, can combine two or more components, or can be with
It is configured with different components.Various parts shown in the drawings can include one or more signal processings and/or dedicated
It is realized in the combination of hardware, software or hardware and software including integrated circuit.
Just the conversion android terminal provided in this embodiment for message format is described in detail below, and the Android is whole
End takes the mobile phone as an example.
Memory 301, the memory 301 can be accessed by CPU302, Peripheral Interface 303 etc., and the memory 301 can
It can also include nonvolatile memory to include high-speed random access memory, such as one or more disk memory,
Flush memory device or other volatile solid-state parts.
The peripheral hardware that outputs and inputs of equipment can be connected to CPU302 and deposited by Peripheral Interface 303, the Peripheral Interface 303
Reservoir 301.
I/O subsystem 309, the I/O subsystem 309 can be by the input/output peripherals in equipment, such as touch screen 312
With other input/control devicess 310, it is connected to Peripheral Interface 303.I/O subsystem 309 may include 3091 He of display controller
For controlling one or more input controllers 3092 of other input/control devicess 310.Wherein, one or more input controls
Device 3092 processed receives electric signal from other input/control devicess 310 or sends electric signal to other input/control devicess 310,
Other input/control devicess 310 may include physical button (push button, rocker buttons etc.), dial, slide switch, behaviour
Vertical pole clicks idler wheel.It is worth noting that input controller 3092 can with it is following any one connect: keyboard, infrared port,
The indicating equipment of USB interface and such as mouse.
Touch screen 312, the touch screen 312 are the input interface and output interface between user's android terminal and user,
Visual output is shown to user, visual output may include figure, text, icon, video etc..
Display controller 3091 in I/O subsystem 309 receives electric signal from touch screen 312 or sends out to touch screen 312
Electric signals.Touch screen 312 detects the contact on touch screen, and the contact that display controller 3091 will test is converted to and is shown
The interaction of user interface object on touch screen 312, i.e. realization human-computer interaction, the user interface being shown on touch screen 312
Object can be the icon of running game, the icon for being networked to corresponding network etc..It is worth noting that equipment can also include light
Mouse, light mouse are the extensions for the touch sensitive surface for not showing the touch sensitive surface visually exported, or formed by touch screen.
RF circuit 305 is mainly used for establishing the communication of mobile phone Yu wireless network (i.e. network side), realizes mobile phone and wireless network
The data receiver of network and transmission.Such as transmitting-receiving short message, Email etc..Specifically, RF circuit 305 receives and sends RF letter
Number, RF signal is also referred to as electromagnetic signal, and RF circuit 305 converts electrical signals to electromagnetic signal or electromagnetic signal is converted to telecommunications
Number, and communicated by the electromagnetic signal with communication network and other equipment.RF circuit 305 may include for executing
The known circuit of these functions comprising but it is not limited to antenna system, RF transceiver, one or more amplifiers, tuner, one
A or multiple oscillators, digital signal processor, CODEC (COder-DECoder, coder) chipset, user identifier mould
Block (Subscriber Identity Module, SIM) etc..
Voicefrequency circuit 306 is mainly used for receiving audio data from Peripheral Interface 303, which is converted to telecommunications
Number, and the electric signal is sent to loudspeaker 311.
Loudspeaker 311 is reduced to sound for mobile phone to be passed through RF circuit 305 from the received voice signal of wireless network
And the sound is played to user.
Power management chip 308, the hardware for being connected by CPU302, I/O subsystem and Peripheral Interface are powered
And power management.
Android terminal provided by the embodiments of the present application may be implemented to be converted into the format of Json format barrage message lattice
Formula realizes the effect quickly shown to the data of the Json format received with barrage message.
Conversion equipment, storage medium and the android terminal of the message format provided in above-described embodiment can be performed the application and appoint
The conversion method of message format provided by embodiment of anticipating has and executes the corresponding functional module of this method and beneficial effect.Not
The technical detail of detailed description in the above-described embodiments, reference can be made to the conversion of message format provided by the application any embodiment
Method.
Note that the above is only a better embodiment of the present invention and the applied technical principle.It will be appreciated by those skilled in the art that
The invention is not limited to the specific embodiments described herein, be able to carry out for a person skilled in the art it is various it is apparent variation,
It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out by above embodiments to the present invention
It is described in further detail, but the present invention is not limited to the above embodiments only, without departing from the inventive concept, also
It may include more other equivalent embodiments, and the scope of the invention is determined by the scope of the appended claims.
Claims (10)
1. a kind of conversion method of message format characterized by comprising
When getting Json data, jsonStr is verified, and in checking procedure, obtains at least one key-value pair information;
At least one described key-value pair information is spliced according to barrage message format, obtains barrage message format.
2. carrying out school to jsonStr the method according to claim 1, wherein described when getting Json data
It tests, and in checking procedure, obtains at least one key-value pair information, comprising:
When getting Json data, by retrieving respectively to jsonStr head and the tail character, and determine whether the head and the tail character is
One Json format standard character;
If so, verifying successfully, it is assigned to jsonStr by the head and the tail character deletion, and by the character string after deletion, is assigned
JsonStr after value;
According to other Json format standard characters in addition to the first Json format standard character, after the assignment
JsonStr is split processing, obtains at least one key-value pair information.
3. according to the method described in claim 2, it is characterized in that, the basis except the first Json format standard character with
Other outer Json format standard characters, are split processing to the jsonStr after the assignment, obtain at least one key-value pair
Information, comprising:
According to the 2nd Json format standard character, processing is split to the jsonStr after the assignment, obtains character string number
Group;
According to the 3rd Json format standard character, processing is split to all character string dimensions, by each character string
Template array tmpArray2 [0] is stored in after array information segmentation, in tmpArray2 [1], obtains at least one key-value pair letter
Breath.
4. according to the method described in claim 3, it is characterized in that, according to the 3rd Json format standard character, to all
The character string dimension is split processing, will be stored at least one template array after the segmentation of each character string dimension information
After in tmpArray2 [0], tmpArray2 [1], the method also includes:
Calling TextUtils.equals (tmpArray 2 is passed through to tmpArray2 [0] data of each template array
[0], " ") method judges whether tmpArray2 [0] data are empty;
If so, returning to jsonStr verifies failure information;
If not, it is determined that the jsonStr is verified successfully.
5. the method according to claim 1, wherein by least one described key-value pair information according to barrage message
Format is spliced, and barrage message format is obtained, comprising:
All key-value pair informations are stored in the map object constructed in advance;
The key information that obtains the key information in map object by calling entry.getKey () method, and will acquire turns
Change the variable of the String type an of key information into;And map is obtained by calling entry.getValue () method
Value information in object, and the value information that will acquire is converted into the variable of the String type an of value information;
By calling change of the stringBuilde to the variable of the String type of key information and the String type of value information
Amount is spliced according to default barrage message format, obtains barrage message format.
6. according to the method described in claim 5, it is characterized in that, described by calling stringBuilde to key information
The variable of the String type of the variable and value information of String type is spliced according to default barrage message format, is obtained
Barrage message format, comprising:
By calling stringBuilde to the variable of the String type of all key informations and the String of value information
The first barrage format standard character is added between the variable of type, forms at least one barrage message key-value pair information;
Second barrage format standard character is added to last position of each barrage message key-value pair information, and will be all
Barrage message key-value pair information is combined into a result character string;
The the second barrage format standard character for deleting last of the result character string, obtains barrage message format.
7. a kind of conversion equipment of message format characterized by comprising
Key-value pair information obtains module and verifies when for getting Json data to jsonStr, and in checking procedure,
Obtain at least one key-value pair information;
Barrage message format splicing module, for spelling at least one described key-value pair information according to barrage message format
It connects, obtains barrage message format.
8. device according to claim 7, which is characterized in that the barrage message format splicing module, comprising:
The first character check unit when for getting Json data, by retrieving respectively to jsonStr head and the tail character, and is sentenced
Whether the fixed head and the tail character is the first Json format standard character;
The first character deletion unit is used for if so, verify successfully, by the head and the tail character deletion, and by the character after deletion
JsonStr of the string assignment to jsonStr, after obtaining assignment;
Key-value pair information acquiring unit, for according to other Json format marks in addition to the first Json format standard character
Quasi- character is split processing to the jsonStr after the assignment, obtains at least one key-value pair information.
9. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the program is held by processor
The conversion method such as message format as claimed in any one of claims 1 to 6 is realized when row.
10. a kind of android terminal, including memory, processor and storage are on a memory and can be in the computer of processor operation
Program, which is characterized in that realize when the processor executes the computer program and disappear as claimed in any one of claims 1 to 6
Cease the conversion method of format.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810718902.7A CN109005469B (en) | 2018-07-03 | 2018-07-03 | Message format conversion method and device, storage medium and android terminal |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810718902.7A CN109005469B (en) | 2018-07-03 | 2018-07-03 | Message format conversion method and device, storage medium and android terminal |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109005469A true CN109005469A (en) | 2018-12-14 |
CN109005469B CN109005469B (en) | 2021-07-23 |
Family
ID=64598948
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810718902.7A Active CN109005469B (en) | 2018-07-03 | 2018-07-03 | Message format conversion method and device, storage medium and android terminal |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109005469B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114339373A (en) * | 2022-03-17 | 2022-04-12 | 飞狐信息技术(天津)有限公司 | Queue barrage generation method and device, storage medium and equipment |
CN116055559A (en) * | 2023-03-28 | 2023-05-02 | 广州九尾信息科技有限公司 | Data exchange format processing method and device |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130007299A1 (en) * | 2011-07-01 | 2013-01-03 | Stoneware, Inc. | Method and apparatus for a keep-alive push agent |
CN103970855A (en) * | 2014-05-06 | 2014-08-06 | 车智互联(北京)科技有限公司 | Device and method for processing data |
CN105117379A (en) * | 2015-09-11 | 2015-12-02 | 广州华多网络科技有限公司 | Automatic program text converting method and device |
CN105354020A (en) * | 2015-09-30 | 2016-02-24 | 武汉钢铁(集团)公司 | Json format data analytic method and data receiving end |
CN106973332A (en) * | 2017-03-10 | 2017-07-21 | 武汉斗鱼网络科技有限公司 | A kind of barrage message treatment method, analytic method and system |
CN107172012A (en) * | 2017-04-18 | 2017-09-15 | 北京思特奇信息技术股份有限公司 | A kind of message format conversion method and system |
CN107465738A (en) * | 2017-08-01 | 2017-12-12 | 深圳市金立通信设备有限公司 | A kind of communication means, server and computer-readable recording medium |
-
2018
- 2018-07-03 CN CN201810718902.7A patent/CN109005469B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130007299A1 (en) * | 2011-07-01 | 2013-01-03 | Stoneware, Inc. | Method and apparatus for a keep-alive push agent |
CN103970855A (en) * | 2014-05-06 | 2014-08-06 | 车智互联(北京)科技有限公司 | Device and method for processing data |
CN105117379A (en) * | 2015-09-11 | 2015-12-02 | 广州华多网络科技有限公司 | Automatic program text converting method and device |
CN105354020A (en) * | 2015-09-30 | 2016-02-24 | 武汉钢铁(集团)公司 | Json format data analytic method and data receiving end |
CN106973332A (en) * | 2017-03-10 | 2017-07-21 | 武汉斗鱼网络科技有限公司 | A kind of barrage message treatment method, analytic method and system |
CN107172012A (en) * | 2017-04-18 | 2017-09-15 | 北京思特奇信息技术股份有限公司 | A kind of message format conversion method and system |
CN107465738A (en) * | 2017-08-01 | 2017-12-12 | 深圳市金立通信设备有限公司 | A kind of communication means, server and computer-readable recording medium |
Non-Patent Citations (1)
Title |
---|
SKY_WUYUXIANG: ""JION数据格式详解"", 《百度文库》 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114339373A (en) * | 2022-03-17 | 2022-04-12 | 飞狐信息技术(天津)有限公司 | Queue barrage generation method and device, storage medium and equipment |
CN114339373B (en) * | 2022-03-17 | 2022-05-27 | 飞狐信息技术(天津)有限公司 | Queue barrage generation method and device, storage medium and equipment |
CN116055559A (en) * | 2023-03-28 | 2023-05-02 | 广州九尾信息科技有限公司 | Data exchange format processing method and device |
CN116055559B (en) * | 2023-03-28 | 2023-12-22 | 广州九尾智能科技有限公司 | Data exchange format processing method and device |
Also Published As
Publication number | Publication date |
---|---|
CN109005469B (en) | 2021-07-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108882006A (en) | A kind of conversion method of message format, device, storage medium and android terminal | |
CN111063353B (en) | Client processing method allowing user-defined voice interactive content and user terminal | |
CN110188185A (en) | Processing method, device, equipment and the storage medium of more wheel dialogues | |
CN108959199A (en) | A kind of log highlights method, apparatus, storage medium and android terminal | |
CN108227953B (en) | Character input method and related product | |
CN109600638B (en) | Live broadcast method and device, electronic equipment and computer readable storage medium | |
CN109614622A (en) | Valid data extracting method, device, storage medium and terminal | |
CN109005469A (en) | A kind of conversion method of message format, device, storage medium and android terminal | |
CN108933968A (en) | A kind of conversion method of message format, device, storage medium and android terminal | |
CN111597107A (en) | Information output method and device and electronic equipment | |
CN110275735A (en) | A kind of interface configuration method, device, terminal and storage medium | |
CN111124627B (en) | Method and device for determining call initiator of application program, terminal and storage medium | |
CN108037839B (en) | Character input method and related product | |
US20220301564A1 (en) | Method for executing instruction, relevant apparatus and computer program product | |
CN109656550A (en) | Json data analysis method, device, equipment and readable storage medium storing program for executing | |
CN115858556A (en) | Data processing method and device, storage medium and electronic equipment | |
CN112291602B (en) | Video playing method, electronic equipment and storage medium | |
CN114968960A (en) | Log processing method and device, computer equipment and storage medium | |
CN116303888A (en) | Rarely used word processing method and device, storage medium and electronic equipment | |
CN108733814B (en) | Search engine preloading method and device, storage medium and terminal | |
CN112379967A (en) | Simulator detection method, device, equipment and medium | |
CN112071313A (en) | Voice broadcasting method and device, electronic equipment and medium | |
CN108932128A (en) | A kind of conversion method of message format, device, storage medium and android terminal | |
CN113553202B (en) | Verification method, device and storage medium for combined message sequence | |
CN108132990B (en) | Method and device for replacing APP built-in picture and storage medium |
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 |