CN104917786A - Method and module for saving transmission flow during interaction of client and server - Google Patents

Method and module for saving transmission flow during interaction of client and server Download PDF

Info

Publication number
CN104917786A
CN104917786A CN201410086232.3A CN201410086232A CN104917786A CN 104917786 A CN104917786 A CN 104917786A CN 201410086232 A CN201410086232 A CN 201410086232A CN 104917786 A CN104917786 A CN 104917786A
Authority
CN
China
Prior art keywords
client
mapping
server
dictionary file
data
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
CN201410086232.3A
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.)
HANGZHOU MOVING MEDIA Co Ltd
Original Assignee
HANGZHOU MOVING MEDIA 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 HANGZHOU MOVING MEDIA Co Ltd filed Critical HANGZHOU MOVING MEDIA Co Ltd
Priority to CN201410086232.3A priority Critical patent/CN104917786A/en
Publication of CN104917786A publication Critical patent/CN104917786A/en
Pending legal-status Critical Current

Links

Abstract

The invention is applicable to the field of Internet communication, and provides a method and a module for saving transmission flow during interaction of a client and a server. The method and the module provided by the invention saves the transmission flow by mapping a dictionary to a client side and a server side synchronously and transmitting data according to compression optimization of the mapping dictionary, and maintains readability and maintainability of codes of the client side and the server side.

Description

A kind of save client and server mutual time the method for delivery flow rate and module
Technical field
The invention belongs to field of Internet communication, particularly relate to a kind of save client and server mutual time the method for delivery flow rate and module.
Background technology
At present, on the Internet, client and server end is mutual, generally adopts http protocol.For the Consumer's Experience obtained, generally all adopt the data of JSON form.So-called JSON (JavaScript Object Notation) form is a kind of data interchange format of lightweight, and the data of this form are easy to people and read and write, and is also easy to machine simultaneously and resolves and generate.JSON form is a subset based on JavaScript Programming Language, Standard ECMA-262 3rd Edition-December 1999.JSON form adopts and is totally independent of the text formatting of language, but also using and be similar to C language family and (comprise C, C++, C#, Java, JavaScript, Perl, Python etc.) custom, the data interchange language that these characteristics make JSON become desirable.
JSON is established in two kinds of structure: a, set (A collection of name/value pairs) that " name/value " is right, in different language, it is understood to object (object), record (record), structure (struct), dictionary (dictionary), Hash table (hash table), there is key list (keyed list), or Associate array (associative array); The ordered list (An ordered list of values) of b, value, in most of language, it is understood to array (array).Current, in programmer's cataloged procedure, in order to make code, there is readability and maintainability, the key character string that normally implication is obvious in the JSON data of definition, such as JSON object: [{ " msgId ": " 618 ", " ower ": 1, " logoImgUrl ": " merchantLogo/81374636245200501.jpg ", " time ": " 2013-08-0117:56:53 ", " type ": " 1 ", " serverInfo ": { " message_id ": " 142 ", " crm_card_type ": " ", " sample_id ": " ", " merchant_id ": " ", " question_id ": " 214 ", " market_research ": " 5 ", " card_id ": " 37 " }, " items ": [{ " content ": " ", " title ": " ", " time ": " ", " linkUrl ": " ", " location ": " ", " imageUrl ": " ", " itemId ": " 142 ", " type ": 5}] }].But in data transmission procedure, the key in these JSON data needs to take very large data traffic.
Summary of the invention
The object of the invention is to: provide a kind of save client and server mutual time the method for delivery flow rate and module, be intended to solve existing JSON transfer of data and take the larger problem of flow.
The object of the present invention is achieved like this:
A kind of save client and server mutual time the method for delivery flow rate, the JSON data that client will be transferred to server carry out compression optimization according to mapping dictionary file, and described mapping dictionary file is the set of the mapping definition of key in predefined JSON data and correspondence.
Described method specifically comprises:
Client obtains the mapping dictionary file on server, and keeps the mapping dictionary file in client and the mapping dictionary file on server synchronous consistent all the time;
Client according to be transferred to server JSON form request msg in original key mapping in dictionary file the mapping definition searching coupling;
Request msg after compression optimization, by after the original key in the mapping definition replacement request data that find, is sent to server by client.
Described method also comprises:
Mapping definition in request msg after the compression optimization that server sends according to client searches corresponding original key mapping in dictionary file, and replaces corresponding mapping definition with the original key found.
Different mapping dictionary files is defined according to server distinct interface.
User end to server request also obtains the mapping dictionary file of corresponding access interface, and is cached to this locality.
The form of described mapping dictionary file be fixing key1: interface name, fixing key2: version, [original key name 1: abbreviation key name 1} ..., { original key name N: abbreviation key name N}] }, N is natural number.
Another object of the present invention is to: a kind of module optimizing client transmissions data is provided, comprises:
File obtaining unit, for obtaining map dictionary file to server request, described mapping dictionary file is the set of the mapping definition of key in predefined JSON data and correspondence;
Data conversion module, searches corresponding mapping definition in the mapping dictionary file obtained at file obtaining unit for the original key in the request msg of the JSON form according to client, and exports after replacing corresponding original key with the mapping definition found.
The present invention also has an object to be: provide a kind of containing the client optimizing the module of client transmissions data as above.
The present invention also has an object to be: provide the data recovery module on a kind of server, comprising:
File output unit, for Storage Mapping dictionary file, and sends to client according to the request of client by mapping dictionary file, and described mapping dictionary file is the set of the mapping definition of key in predefined JSON data and correspondence;
Data conversion module, searches corresponding original key for the mapping definition in the data after the compression optimization that sends according to client mapping in dictionary file, and exports after replacing corresponding mapping definition with the original key found.
The present invention also has an object to be: provide a kind of save client and server mutual time the system of delivery flow rate, comprise the data-optimized module in client and the data recovery module on server,
Described data-optimized module comprises: file obtaining unit, and for obtaining map dictionary file to server request, described mapping dictionary file is the set of the mapping definition of key in predefined JSON data and correspondence; Data conversion module, searches corresponding mapping definition in the mapping dictionary file obtained at file obtaining unit for the original key in the request msg of the JSON form according to client, and exports after replacing corresponding original key with the mapping definition found;
Described data recovery module comprises file output unit, for Storage Mapping dictionary file, and according to the request of client, mapping dictionary file is sent to client; Data conversion module, searches corresponding original key for the mapping definition in the data after the compression optimization that sends according to client mapping in dictionary file, and exports after replacing corresponding mapping definition with the original key found.
Outstanding advantages of the present invention is: the present invention passes through at client and server end synchronization map dictionary, and according to mapping dictionary compression optimized transmission data, saves delivery flow rate, still keep readability, the maintainability of the code of client and server end simultaneously.
Accompanying drawing explanation
Fig. 1 be saving client and server that the embodiment of the present invention provides mutual time the flow process sequential chart of method of delivery flow rate.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, be not intended to limit the present invention.
The present invention passes through at client and server end synchronization map dictionary, and according to mapping dictionary compression optimized transmission data, saves delivery flow rate, still keep readability, the maintainability of the code of client and server end simultaneously.
Specifically, be exactly that an abbreviation is defined all respectively for the key of JSON data, such as: definition key:message_id is abbreviated as f, namely key in JSON data and the abbreviation of correspondence thereof constitute mapping dictionary, mapping dictionary that can be different according to the interface definition that server is different, also can be integrated in one and map in dictionary by all key and abbreviation thereof.
Fig. 1 show saving client and server that the embodiment of the present invention provides mutual time the flow process sequential of method of delivery flow rate.
User's application software of fixing on/mobile communication terminal (i.e. client) obtains the mapping dictionary file on application server, and keeps the mapping dictionary file on user terminal synchronous consistent all the time with the mapping dictionary file of application server end.
In embodiments of the present invention, different mapping dictionaries is defined according to server distinct interface.When application software initiated, to the mapping dictionary file of each interface of server request (or access interface of correspondence), this mapping dictionary file can select following form: { fixing key1: interface name, fixing key2: version, [{ original key name 1: abbreviation key name 1}, ... original key name N: abbreviation key name N}] }, N is natural number.Such as: { " if ": " getUserInfo ", " v ": " 1.0.1.1 ", [{ " message_id ": " f " }, { " market_research ": " k " }, { " crm_card_type ": " g " }] }.This mapping dictionary file can be cached to local to improve performance by user terminal.
When user end to server initiates request, client adopts JSON form assembling request msg, and obtain corresponding mapping dictionary file according to the server interface that client will be accessed, and according to this mapping dictionary file, compression optimization is carried out to the request msg of having assembled, namely in mapping dictionary file, the mapping definition of coupling (namely abridge key) is found according to the original key in request msg, and with the original key in these mapping definition replacement request data.
After having optimized, the request msg after optimization is passed to the corresponding interface of server by client by http protocol.
After server interface receives the request msg after client optimization, according to identical mapping dictionary file, the abbreviation key in the request msg after optimization is reverted to original key name, then carries out request process thereafter, finally result is returned to client.
After adopting method provided by the invention, greatly can save data transfer throughput, speeding up data transmission speed.
Such as, the transferring content before method provided by the invention is adopted to be: [{ " msgId ": " 618 ", " ower ": 1, " logoImgUrl ": " merchantLogo/81374636245200501.jpg ", " time ": " 2013-08-0117:56:53 ", " type ": " 1 ", " serverInfo ": { " message_id ": " 142 ", " crm_card_type ": " ", " sample_id ": " ", " merchant_id ": " ", " question_id ": " 214 ", " market_research ": " 5 ", " card_id ": " 37 " }, " items ": [{ " content ": " ", " title ": " ", " time ": " ", " linkUrl ": " ", " location ": " ", " imageUrl ": " ", " itemId ": " 142 ", " type ": 5}] }], about 371 bytes altogether.
Accordingly, the transferring content after method optimization provided by the invention is adopted to be: [{ " a ": " 618 ", " b ": 1, " c ": " merchantLogo/81374636245200501.jpg ", " d ": " 2013-08-0117:56:53 ", " e ": " 1 ", " s ": { " f ": " 142 ", " g ": " ", " h ": " ", " i ": " ", " j ": " 214 ", " k ": " 5 ", " u ": " 37 " }, " t ": [{ " l ": " ", " m ": " ", " d ": " ", " o ": " ", " p ": " ", " q ": " ", " r ": " 142 ", " e ": 5}]], about 232 bytes altogether.This content-data of the every transmission primaries of user can save 139 bytes, and source code simultaneously still has readability and maintainability.
For realizing said method, client need contain a data-optimized module, and this module both can be contained in application software, also can independent of application software, and this module at least comprises: file obtaining unit, maps dictionary file for also obtaining to server request; Data conversion module, searches corresponding mapping definition in the mapping dictionary file obtained at file obtaining unit for the original key in the request msg of the JSON form according to client, and exports after replacing corresponding original key with the mapping definition found.Accordingly, also there is a data recovery module at server end, at least comprise: file output unit, for Storage Mapping dictionary file, and according to the request of client, mapping dictionary file is sent to client; Data conversion module, searches corresponding original key for the mapping definition in the data after the compression optimization that sends according to client mapping in dictionary file, and exports after replacing corresponding mapping definition with the original key found.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any amendments done within the spirit and principles in the present invention, equivalent replacement and improvement etc., all should be included within protection scope of the present invention.

Claims (10)

1. one kind save client and server mutual time the method for delivery flow rate, it is characterized in that, the JSON data that client will be transferred to server carry out compression optimization according to mapping dictionary file, and described mapping dictionary file is the set of the mapping definition of key in predefined JSON data and correspondence.
2. the method for delivery flow rate when saving client and server as claimed in claim 1 is mutual, it is characterized in that, described method specifically comprises:
Client obtains the mapping dictionary file on server, and keeps the mapping dictionary file in client and the mapping dictionary file on server synchronous consistent all the time;
Client according to be transferred to server JSON form request msg in original key mapping in dictionary file the mapping definition searching coupling;
Request msg after compression optimization, by after the original key in the mapping definition replacement request data that find, is sent to server by client.
3. the method for delivery flow rate when saving client and server as claimed in claim 2 is mutual, it is characterized in that, described method also comprises:
Mapping definition in request msg after the compression optimization that server sends according to client searches corresponding original key mapping in dictionary file, and replaces corresponding mapping definition with the original key found.
4. the method for delivery flow rate when saving client and server as claimed in claim 2 is mutual, is characterized in that, define different mapping dictionary files according to server distinct interface.
5. the method for delivery flow rate when saving client and server as claimed in claim 4 is mutual, is characterized in that, user end to server request also obtains the mapping dictionary file of corresponding access interface, and is cached to this locality.
6. the method for delivery flow rate when saving client and server as claimed in claim 5 is mutual, it is characterized in that, the form of described mapping dictionary file is { fixing key1: interface name, fixing key2: version, [{ original key name 1: abbreviation key name 1}, ..., original key name N: abbreviation key name N}] }, N is natural number.
7. optimize a module for client transmissions data, it is characterized in that, comprising:
File obtaining unit, for obtaining map dictionary file to server request, described mapping dictionary file is the set of the mapping definition of key in predefined JSON data and correspondence;
Data conversion module, searches corresponding mapping definition in the mapping dictionary file obtained at file obtaining unit for the original key in the request msg of the JSON form according to client, and exports after replacing corresponding original key with the mapping definition found.
8. the client containing, for example the module of optimization client transmissions data according to claim 7.
9. the data recovery module on server, is characterized in that, comprising:
File output unit, for Storage Mapping dictionary file, and sends to client according to the request of client by mapping dictionary file, and described mapping dictionary file is the set of the mapping definition of key in predefined JSON data and correspondence;
Data conversion module, searches corresponding original key for the mapping definition in the data after the compression optimization that sends according to client mapping in dictionary file, and exports after replacing corresponding mapping definition with the original key found.
10. save client and server mutual time the system of delivery flow rate, it is characterized in that, comprise the data-optimized module in client and the data recovery module on server,
Described data-optimized module comprises: file obtaining unit, and for obtaining map dictionary file to server request, described mapping dictionary file is the set of the mapping definition of key in predefined JSON data and correspondence; Data conversion module, searches corresponding mapping definition in the mapping dictionary file obtained at file obtaining unit for the original key in the request msg of the JSON form according to client, and exports after replacing corresponding original key with the mapping definition found;
Described data recovery module comprises file output unit, for Storage Mapping dictionary file, and according to the request of client, mapping dictionary file is sent to client; Data conversion module, searches corresponding original key for the mapping definition in the data after the compression optimization that sends according to client mapping in dictionary file, and exports after replacing corresponding mapping definition with the original key found.
CN201410086232.3A 2014-03-11 2014-03-11 Method and module for saving transmission flow during interaction of client and server Pending CN104917786A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410086232.3A CN104917786A (en) 2014-03-11 2014-03-11 Method and module for saving transmission flow during interaction of client and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410086232.3A CN104917786A (en) 2014-03-11 2014-03-11 Method and module for saving transmission flow during interaction of client and server

Publications (1)

Publication Number Publication Date
CN104917786A true CN104917786A (en) 2015-09-16

Family

ID=54086490

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410086232.3A Pending CN104917786A (en) 2014-03-11 2014-03-11 Method and module for saving transmission flow during interaction of client and server

Country Status (1)

Country Link
CN (1) CN104917786A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105630870A (en) * 2015-12-16 2016-06-01 广州神马移动信息科技有限公司 Sear request processing method and system
CN107645538A (en) * 2017-08-14 2018-01-30 阿里巴巴集团控股有限公司 The method and device and electronic equipment of dynamic compression dictionary are provided
CN108011952A (en) * 2017-12-01 2018-05-08 北京奇艺世纪科技有限公司 A kind of method and apparatus for obtaining compression dictionary
CN108092956A (en) * 2017-12-01 2018-05-29 北京奇艺世纪科技有限公司 A kind of method and apparatus for obtaining compression dictionary
CN108156173A (en) * 2018-01-09 2018-06-12 江苏徐工信息技术股份有限公司 A kind of dynamic lossless compression method of JSON data packets
CN109450450A (en) * 2018-10-17 2019-03-08 杭州费尔斯通科技有限公司 A kind of compression of JSON data real non-destructive and decompressing method
WO2019100937A1 (en) * 2017-11-27 2019-05-31 电信科学技术研究院有限公司 Method and apparatus for data transmission

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030005181A1 (en) * 2001-07-02 2003-01-02 David Bau Annotation based development platform for asynchronous web services
CN1547326A (en) * 2003-11-28 2004-11-17 北京大学 Extensible Markup Language (XML) data stream compressor and compression method thereof
CN101500210A (en) * 2009-03-16 2009-08-05 北京北纬点易信息技术有限公司 Instant communication method with low transmission load based on XMPP protocol and system thereof
CN102981841A (en) * 2011-11-08 2013-03-20 微软公司 External serialization and deserialization
CN103312822A (en) * 2013-07-05 2013-09-18 福建邮科通信技术有限公司 Push-based SNS protocol optimization method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030005181A1 (en) * 2001-07-02 2003-01-02 David Bau Annotation based development platform for asynchronous web services
CN1547326A (en) * 2003-11-28 2004-11-17 北京大学 Extensible Markup Language (XML) data stream compressor and compression method thereof
CN101500210A (en) * 2009-03-16 2009-08-05 北京北纬点易信息技术有限公司 Instant communication method with low transmission load based on XMPP protocol and system thereof
CN102981841A (en) * 2011-11-08 2013-03-20 微软公司 External serialization and deserialization
CN103312822A (en) * 2013-07-05 2013-09-18 福建邮科通信技术有限公司 Push-based SNS protocol optimization method

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105630870A (en) * 2015-12-16 2016-06-01 广州神马移动信息科技有限公司 Sear request processing method and system
CN107645538A (en) * 2017-08-14 2018-01-30 阿里巴巴集团控股有限公司 The method and device and electronic equipment of dynamic compression dictionary are provided
WO2019100937A1 (en) * 2017-11-27 2019-05-31 电信科学技术研究院有限公司 Method and apparatus for data transmission
CN108011952A (en) * 2017-12-01 2018-05-08 北京奇艺世纪科技有限公司 A kind of method and apparatus for obtaining compression dictionary
CN108092956A (en) * 2017-12-01 2018-05-29 北京奇艺世纪科技有限公司 A kind of method and apparatus for obtaining compression dictionary
CN108092956B (en) * 2017-12-01 2020-12-04 北京奇艺世纪科技有限公司 Method and device for acquiring compression dictionary
CN108011952B (en) * 2017-12-01 2021-06-18 北京奇艺世纪科技有限公司 Method and device for acquiring compression dictionary
CN108156173A (en) * 2018-01-09 2018-06-12 江苏徐工信息技术股份有限公司 A kind of dynamic lossless compression method of JSON data packets
CN109450450A (en) * 2018-10-17 2019-03-08 杭州费尔斯通科技有限公司 A kind of compression of JSON data real non-destructive and decompressing method

Similar Documents

Publication Publication Date Title
CN104917786A (en) Method and module for saving transmission flow during interaction of client and server
CN101778168B (en) Method and system for optimization display of wed pages on browser of mobile terminal
CN101668004B (en) A kind of webpage acquisition methods, Apparatus and system
JP4982455B2 (en) Mobile web service system and method
CN101807207B (en) Method for sharing document based on content difference comparison
CN104753966A (en) Resource file inquiry method and system based on server and client caches
CN104636477B (en) The De-weight method of push list before a kind of information push
CN103389969A (en) Method, device and system for previewing PDF (portable document format) file on mobile terminal
CN102436513A (en) Distributed search method and system
CN103532984B (en) Data transmission method, device and system of websocket protocol
CN103279474A (en) Video file index method and system
CN103514189A (en) Implementing method for web crawler based on search engines
CN105354020A (en) Json format data analytic method and data receiving end
CN102750300B (en) High-performance unstructured data access protocol supporting multi-granularity searching.
CN103853714A (en) Data processing method and device
CN103581224A (en) Method and device for pushing information
CN104077310A (en) Method, equipment and system for loading resource file
CN104035993A (en) Memory search method for e-books, e-book management system and reading system
CN102622344A (en) Control method and control system for picture batch uploading facing to Mediawiki
CN101751408A (en) System and method of internet in text advertisements
CN106919696B (en) SEO site construction method and SEO request response method
CN103079194A (en) Method, device and system of service adaptation
CN101997883A (en) Network structure of mobile website for mobile terminal access
CN102572100A (en) Method for realizing menu query by mobile phone
CN104301182A (en) Method and device for inquiring slow website access abnormal information

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20150916