CN109871203A - Optimization transmission method, device and the electronic equipment of network request parameter - Google Patents
Optimization transmission method, device and the electronic equipment of network request parameter Download PDFInfo
- Publication number
- CN109871203A CN109871203A CN201811648338.2A CN201811648338A CN109871203A CN 109871203 A CN109871203 A CN 109871203A CN 201811648338 A CN201811648338 A CN 201811648338A CN 109871203 A CN109871203 A CN 109871203A
- Authority
- CN
- China
- Prior art keywords
- assignment
- hashmap
- data
- network request
- type
- 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
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the present invention provides optimization transmission method, device and the electronic equipment of a kind of network request parameter, the method comprise the steps that the custom object in the software development network architecture, and assignment is carried out to the object using target network required parameter;Object after assignment is converted into HashMap categorical data, and the HashMap categorical data is transmitted.The embodiment of the present invention safeguards the assignment procedure of multiple network request parameters using object, and in parameter transmittance process, object is converted into the corresponding HashMap data type of@FieldMap, can more convenient and fast maintenance and management network request parameter, and more effectively improve network request parameter transmitting reliability.
Description
Technical field
The present embodiments relate to technical field of software development, more particularly, to a kind of optimization of network request parameter
Transmission method, device and electronic equipment.
Background technique
In the development process of the mobile terminal Android, Retrofit network frame is generallyd use to realize that specific network is asked
It asks.During network request, front-end and back-end server-side needs interaction to link up, and this process is generally joined by network request
Number transmitting is to realize.There are two types of the modes usually requested, and get mode requests to request with post mode.Background server is to parameter
It is parsed, then executes corresponding logical operation.
In business demand development process, there are many scenes for needing user's submission form information for meeting.In submission form
In the case of, network request is carried out usually using post request method, and can be in Retrofit network frame, by making
With@Field ,@FieldMap or@Body etc., the transmitting of parameter is made requests.
When required parameter is excessive, such as the scene of submission form information ,@is used using@Body Transfer Parameters ratio
FieldMap is easy maintenance.The advantages of@Body, is: passing parameter without using many@Field labels, does not also need ginseng
Ginseng is passed in number all put to@FieldMap labels, and only needs to define a class object, and be the object value, then will be after assignment
Object pass to@Body label.
It but is that object is converted into a json character string to pass to again during using@Body Transfer Parameters
Server-side, and rear end server-side needs to carry out the json character string json parsing, could obtain corresponding solicited message.So
And due to the diversity of server-side, so that partial service end has difficulties even to json parsing and does not have json parsing function,
Lead to that required parameter transmission efficiency is low, effect is poor, or even transmitting failure.
Summary of the invention
In order to overcome the above problem or at least be partially solved the above problem, the embodiment of the present invention provides a kind of network and asks
Optimization transmission method, device and the electronic equipment for seeking parameter to more convenient and fast maintenance and management network request parameter, and more have
The reliability for improving the transmitting of network request parameter of effect.
In a first aspect, the embodiment of the present invention provides a kind of optimization transmission method of network request parameter, comprising:
The custom object in the software development network architecture, and the object is assigned using target network required parameter
Value;
Object after assignment is converted into HashMap categorical data, and the HashMap categorical data is transmitted.
Second aspect, the embodiment of the present invention provide a kind of optimization transfer device of network request parameter, comprising:
Assignment module for the custom object in the software development network architecture, and utilizes target network required parameter pair
The object carries out assignment;
Transfer module is converted, for the object after assignment to be converted to HashMap categorical data, and to the HashMap
Categorical data is transmitted.
The third aspect, the embodiment of the present invention provide a kind of electronic equipment, comprising: at least one processor, at least one
Manage device, communication interface and bus;The memory, the processor and the communication interface are completed mutual by the bus
Communication, the communication interface sends the information between terminal for the electronic equipment and target network required parameter and transmits;
The computer program that can be run on the processor is stored in the memory, the processor executes the computer journey
When sequence, the optimization transmission method of network request parameter described in first aspect as above is realized.
Fourth aspect, the embodiment of the present invention provide a kind of non-transient computer readable storage medium, the non-transient calculating
Machine readable storage medium storing program for executing stores computer instruction, and the computer instruction executes the computer described in first aspect as above
The optimization transmission method of network request parameter.
Optimization transmission method, device and the electronic equipment of network request parameter provided in an embodiment of the present invention, using object
Safeguard the assignment procedure of multiple network request parameters, and in parameter transmittance process, it is corresponding that object is converted into@FieldMap
HashMap data type, can more convenient and fast maintenance and management network request parameter, and more effectively improve network request ginseng
The reliability of number transmitting.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below
There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is this hair
Bright some embodiments for those of ordinary skill in the art without creative efforts, can be with root
Other attached drawings are obtained according to these attached drawings.
Fig. 1 is the flow diagram of the optimization transmission method of network request parameter provided in an embodiment of the present invention;
Fig. 2 is the structural schematic diagram of the optimization transfer device of network request parameter provided in an embodiment of the present invention;
Fig. 3 is the entity structure schematic diagram of electronic equipment provided in an embodiment of the present invention.
Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the embodiment of the present invention, instead of all the embodiments.Based on the embodiment in the embodiment of the present invention, ability
Domain those of ordinary skill every other embodiment obtained without making creative work, belongs to the present invention
The range of embodiment protection.
In the development process of the mobile terminal Android, using Retrofit network frame come when realizing specific network request,
Network request parameter can be transmitted by using@Body to realize.But during using@Body Transfer Parameters, be by
Object is converted into a json character string and passes to server-side again, and rear end server-side needs to carry out json to the json character string
Parsing, could obtain corresponding solicited message.However, due to the diversity of server-side, so that partial service end parses json
It has difficulties and does not have json parsing function even, lead to that required parameter transmission efficiency is low, effect is poor, or even transmitting fails.
In view of the above-mentioned problems, the embodiment of the present invention safeguards the assignment procedure of multiple network request parameters using object, and
In parameter transmittance process, object is converted into HashMap data type, this data type is that most of server-sides are supported
General data type, make it possible to more convenient and fast maintenance and management network request parameter, and more effectively improve network request
The reliability of parameter transmitting.Expansion explanation and introduction will be carried out to the embodiment of the present invention especially by multiple embodiments below.
Fig. 1 is the flow diagram of the optimization transmission method of network request parameter provided in an embodiment of the present invention, comprising:
S101, the custom object in the software development network architecture, and object is carried out using target network required parameter
Assignment.
The embodiment of the present invention mainly optimizes the problem of multiple network request parameters are transmitted in Retrofit network frame.
When being transmitted to multiple network request parameters, according in Retrofit network frame the characteristics of@Body and@FieldMap,
The assignment of each network request parameter is realized in the form of object, so as to using object come to each network request parameter into
Row maintenance and processing.
Specifically, when being handled, first in the software development network architecture, in Retrofit network frame, according to
Network request parameter to be passed, i.e. target network required parameter, a customized object.Then, sharp respectively for the object
Assignment is carried out to it with each target network required parameter, the object after obtaining assignment.Wherein, including object refers in programming language
The one section of significant region deposited, after carrying out assignment to it using target network required parameter, can be used as one it is right
As example is loaded in memory, which can have relevant member variable and member function, to indicate object
Each attribute, i.e. object properties.
Object after assignment is converted to HashMap categorical data, and transmitted to HashMap categorical data by S102.
It is to be understood that when being transmitted to the object after target network required parameter carries out assignment, not to the tax
Object after value is directly transmitted, but the structure type for being first HashMap by the data type conversion of its object properties,
Then the object after converted assignment becomes HashMap categorical data, and then passes to the HashMap categorical data
It passs.It is understood that wherein HashMap categorical data is one group of data stored in the form of key=value.
That is, for the object after assignment, the data type of each object properties is and target network required parameter
Corresponding data type, can be used as original data type.It, will be each when carrying out the conversion of HashMap structure to the object after assignment
The original data type of object properties is converted to the form of key=value, and this form is basic network data parameter transmitting
Format can be identified and be parsed by common data transmission segment.
The optimization transmission method of network request parameter provided in an embodiment of the present invention safeguards that multiple networks are asked using object
The assignment procedure of parameter is sought, and in parameter transmittance process, object is converted into HashMap data type, it can more easily
Maintenance and management network request parameter, and more effectively improve the reliability of network request parameter transmitting.
Wherein, according to the above embodiments optionally, the step of object after assignment being converted into HashMap categorical data
It specifically includes: the data type of object properties in the object after reading assignment, and it is corresponding based on data type and data type
Object after assignment is converted to HashMap categorical data using Java reflection mechanism by default transformation rule.
It is to be understood that the data type of each parameter may not be identical, example in all target network required parameters
It such as may include class, String, List, Map, set, array or custom object.Then utilize these target networks request ginseng
After several pairs of objects carry out assignment, for the object after assignment, the value of the data type of object properties it is corresponding can value be class,
String, List, Map, set, array or custom object etc..It is appreciated that the data type of object properties may include
State the one or more in various data types.
For different data types, when it is converted to HashMap data type, the process of processing can not be complete
It is exactly the same, therefore corresponding different data type, have different conversion process modes.In order in the data for knowing object properties
After type, fast and accurately the data type of the object properties can be converted, various possible data can be corresponded to
Type presets corresponding transformation rule, obtains default transformation rule.
Then, when being converted to the object after assignment, the data of each object properties in the object after first obtaining the assignment
Type searches the default transformation rule corresponding to it further according to the data type, recycles Java reflection mechanism, default according to this
Transformation rule converts the data type of each object properties.That is, the original data type of object type is converted to key=
The HashMap categorical data of value form.
It is understood that Java reflection mechanism therein indicates, in operating status, for any one object, all
Can dynamic call its any means and attribute, i.e., with the information and dynamic call object letter of dynamic acquisition any object
Several functions.
The optimization transmission method of network request parameter provided in an embodiment of the present invention, by the data for first obtaining object properties
Type is targetedly converted object instance to using Java reflection mechanism further according to the different types of data of acquisition
The data type of HashMap structure passes to Retrofit network frame, can effectively improve the accuracy of data conversion and turn
Change efficiency.
Wherein, according to the above embodiments optionally, if the value of data type is custom object, it is based on data class
Type and the corresponding default transformation rule of data type, the step of object after assignment is converted to HashMap categorical data, are specific
It include: all object properties of the object using recursive algorithm, after obtaining assignment, and each object properties are carried out respectively
The conversion of HashMap structure obtains HashMap categorical data.
According to the above embodiments it is found that the method for the embodiment of the present invention supports the data type of custom object.Then when
It, can be according to certainly to the conversion of the object properties when in the object after assignment including the object properties that data type is custom object
The corresponding default transformation rule of object is defined to carry out.Specifically, first being obtained in all custom objects using recursive algorithm
All object properties, then the conversion of progress HashMap structure parallel to each object properties respectively.In the result converted,
Data made of each object properties conversion are the forms exported in parallel, and the form of non-object nesting.
That is, for example, making two objects A and B by oneself, wherein B is A when in object properties further including other objects
An attribute attribute B is similarly converted, i.e., B is also converted into then during A is converted to HashMap
HashMap is simultaneously added in final HashMap, rather than is converted and obtained nested under nested form with B to A
HashMap transformation result.Specific conversion process is, according to the reflection mechanism of Java, the institute of the available object to after assignment
Have object properties attribute-name and corresponding attribute value, then they are converted to the form of key=value one by one, and be added to
In final HashMap.
The optimization transmission method of network request parameter provided in an embodiment of the present invention, being capable of recursive solution to custom object
Analysis, does not use nested behavior, the access for data of being more convenient for.
Wherein, according to the above embodiments optionally, if the value of data type is class, and including parent and subclass, then
Based on the corresponding default transformation rule of data type and data type, the object after assignment is converted into HashMap categorical data
The step of specifically include: using Java reflection mechanism, obtained in the object properties of class data type respectively in parent and subclass
All object properties, and using the object properties in subclass, cover object category identical with the object properties in subclass in parent
Property;Object properties in parent and subclass after covering are carried out with the conversion of HashMap structure respectively, obtains HashMap class
Type data.
It is to be understood that the embodiment of the present invention supports the succession of class, the object properties in parent can be obtained, and support
Object properties in parent are identical as the attribute-name of object properties in subclass.When specific processing, covered with the object properties of subclass
Object properties in parent.Specifically, for using class as the object after the assignment of data type, meeting in the object after the assignment
There are two levels of parent and subclass.Then when carrying out HashMap data type conversion, reflected first with the Java of Development Framework
Mechanism obtains the object properties in parent and subclass respectively, searches again for the object properties and subclass of parent in all parents and subclass
The identical parent of object properties and subclass, with the object category of the object properties of the subclass with same object attribute covering parent
Property.
It include pair there is no the subclass of same object attribute and parent then after above-mentioned covering, in remaining object properties
As attribute, and there are the object properties of the subclass of same object attribute, these object properties constitute the parent after covering and
Object properties in subclass.Then these object properties are converted into the form of HashMap structure respectively, is obtained final
HashMap categorical data.
Wherein, according to the above embodiments optionally, if the value of data type is List, set or array, respectively will
All object properties in object after assignment are converted to the character string of HashMap structure type, and use searching loop method, will
The character string of all HashMap structure types is spliced using given character, and will whole spliced character string conduct
HashMap categorical data;
If the value of data type is Map, the object properties in the object after assignment are directly added to HashMap class
Type data;
If the value of data type is String, the attribute-name and attribute of the object properties of String type are obtained respectively
Value, and HashMap object is constructed, the attribute-name and attribute value are added in HashMap object.
It is to be understood that the method for the embodiment of the present invention on the basis of the various embodiments described above, also supports List, set, number
The conversion and transmitting of group, Map and String data type.For different data types, advised using different default conversions
Then converted.Specifically, being the object properties of List, set or array for the data type of object properties, first by its turn
It is changed to the form of the key=value of HashMap structure type, multiple value are had for list, set and array, then are used
Searching loop method splices multiple value using specified character, such as comma, and using the entirety of splicing as one
Value value is transmitted.It is understood that each object properties converted after value and spliced value be with
The type of character string is accessed.
For example, by taking list type as an example: assuming that having an attribute in object is List list;For its assignment: list.add ("
A "), list.add (" b "), list.add (" c ") when being converted to HashMap, loop through list, its data are spelled
It connects, result a, b, c, wherein connector is defaulted as comma, and user can carry out formulation modification.Finally, using put method, it will
It is added in HashMap object: put (" list ", " a, b, c ").
The embodiment of the present invention finally converts objects into the data of a HashMap type, is Map's for data type
Object properties, itself storage form is the form of key=value, then when being converted, is directly added to assignment
In HashMap made of object conversion afterwards.
The object properties for being String for data type, if there are two String attribute sex and age in object A.It is logical
Reflection technology is crossed, obtains attribute-name using field.getName (), obtains attribute value using field.get (obj).In addition,
A HashMap object is constructed, sex and age are added to the HashMap object of construction using put (name, value) method
In.
The optimization transmission method of network request parameter provided in an embodiment of the present invention, by array, list, set type
The automatic Mosaic of data, and the corresponding conversion to Map and String categorical data, can support array, list, set etc. more
The conversion of seed type data supports data type more extensive.
On the basis of the various embodiments described above, using target network required parameter to object carry out assignment the step of it
Before, the method for the embodiment of the present invention further include: according to default unified scoring criteria, to not by the optional network request of user's assignment
Parameter carries out system and unifies assignment;Wherein, presetting unified scoring criteria is to be established previously according to user's setting to optional network
The scoring criteria of required parameter.
Specifically, can there is a situation where such when interacting with server-side: some network request parameters are optional
Parameter, i.e. user are not required items to its assignment.For example, it is desired to transmitting network request parameter include: name, age and
Sex, sex therein are not required items, are optional network request parameter.It is not assigned when optional network request parameter
In the case of, if also need to transmit the optional network request parameter? what value should be transmitted when transmitting the optional network request parameter?
For this problem, the settling mode of@Body is the parameter for not transmitting not assignment, that is, optional network request parameter is not transmitted, this
It will lead to that there are limitations using@Body label, cannot flexibly handle a variety of demand scenes.
In fact, for by the parameter sex of user's assignment, different places can not be realized according to different application demands
Reason mode, such as: the field is not transmitted;The field is transmitted, but is worth for sky;The field is transmitted, and value is that parameter is transmitted end and connect
The data of receiving end agreement.
It then, can be right in advance in order to flexibly be adapted to different application scenarios and keep the integrality of network request parameter
Optional network request parameter carries out unified assignment.Specifically, being carried out using object of the target network required parameter to definition
Before assignment, assignment first is carried out according to default unified scoring criteria to optional network request parameter therein.And this is default unified
Scoring criteria can be established in advance according to the directly setting of user, be also possible to the system default setting confirmed by user.Separately
Outside, the value at network request parameter transmitting end and receiving end Uniform provisions is also possible to the assignment of optional network request parameter, this
Sample is convenient for processing of the receiving end to data.
For example, being assigned a value of " null " to optional network request parameter, then in the default unified scoring criteria being previously set
For the optional network request parameter sex in above-mentioned network request parameter, in the case where user does not carry out assignment to it, by being
System is to its assignment: sex=null.It is normally carried out subsequent assignment, conversion and conveying flow again later.
The optimization transmission method of network request parameter provided in an embodiment of the present invention, by optional to what is be not user-operably
The unified assignment of network request parameter enables a system to normally carry out conversion process and biography to the optional network request parameter
It passs, can preferably keep the integrality of network request parameter.
In addition, on the basis of the various embodiments described above, the data type of object properties in reading the object after assignment
After step, the method for the embodiment of the present invention further include: the assignment of reading object attribute, and it is based on data type and object properties
Assignment, whether the assignment of eavesdropping target's attribute is Java default value;
After the step of being transmitted to HashMap categorical data, the method for the embodiment of the present invention further include: if object
The assignment of attribute is not Java default value, then parses to HashMap categorical data, otherwise, not to HashMap number of types
According to being parsed.
Specifically, Java can be to the basic data type attribute in data with default value, for example, int type data are silent
Recognize and is assigned a value of 0, boolean type data default value as false.In this way, during parsing object, it can obtain respectively
The assignment and data type of its attribute, and the specific assignment by judging data type belonging to its attribute and attribute, judgement
It is user's assignment or Java default value.For example, being false by the value for obtaining boolean type attribute a, can sentence
The fixed attribute is Java default value.It is understood that attribute therein is object properties.
Correspondingly, can be solved to the HashMap categorical data after being transmitted to HashMap categorical data
Analysis, to obtain primitive network required parameter, to obtain network request information.Specifically, it is contemplated that Java default value is simultaneously
The specifying information that corresponding network required parameter cannot be embodied is knowing the object properties of object according to the judgement of above-mentioned process flow
On the basis of whether assignment is Java default value, if the assignment is not Java default value, to received HashMap type
Data are parsed, otherwise without parsing.
The optimization transmission method of network request parameter provided in an embodiment of the present invention, is sentenced by the assignment to object properties
It is disconnected, support that differentiating the default value of basic parameter type is user's assignment behavior, and support to judge whether to parse in conversion process
Not by the optional parameters of user's assignment, to the network request parameter of system default assignment without parsing, can effectively improve
Analyzing efficiency.Simultaneously because system default assignment is usually unable to embody the specifying information of network request, therefore it is not carried out
Parsing will not influence the parsing result to network request information.
As the other side of the embodiment of the present invention, the embodiment of the present invention provides a kind of network according to the above embodiments
The optimization transfer device of required parameter, the device for realizing the optimization transmitting of network request parameter in the above embodiments.
Therefore, the description and definition in the optimization transmission method of the network request parameter of the various embodiments described above, can be used for the present invention
The understanding of each execution module in embodiment, specifically refers to above-described embodiment, is not repeating herein.
One embodiment of present aspect according to the present invention, structure such as Fig. 2 institute of the optimization transfer device of network request parameter
Show, is the structural schematic diagram of the optimization transfer device of network request parameter provided in an embodiment of the present invention.The device can be used for
Realize the optimization transmitting of network request parameter in above-mentioned each method embodiment, which includes: assignment module 201 and conversion transmitting
Module 202.Wherein:
Assignment module 201 is used for the custom object in the software development network architecture, and utilizes target network required parameter
Assignment is carried out to object;Conversion transfer module 202 is used to the object after assignment being converted to HashMap categorical data, and right
HashMap categorical data is transmitted.
It is transmitted in Retrofit network frame specifically, the optimization transfer device of the embodiment of the present invention mainly optimizes
The problem of multiple network request parameters.When being transmitted to multiple network request parameters, realized in the form of object each
The assignment of a network request parameter, so that each network request parameter is safeguarded and handled using object.That is,
By assignment module 201 first in the software development network architecture, in Retrofit network frame, according to target network required parameter,
A customized object.Then, it for the object, is utilized respectively each target network required parameter and assignment is carried out to it, assigned
Object after value.
Later, data type conversion and transmitting are carried out to the object after above-mentioned assignment by conversion transfer module 202.Specifically
, when 202 pairs of the conversion transfer module objects after target network required parameter carries out assignment transmit, not to the assignment
Object afterwards is directly transmitted, but the structure type for being first HashMap by the data type conversion of its object properties, then
After converted, the object after assignment is i.e. corresponding as HashMap categorical data.Later, conversion transfer module 202 is again to this
HashMap categorical data is transmitted.
That is, after 201 assignment of assignment module, for the object after assignment, the data type of each object properties
It is data type corresponding with target network required parameter, can be used as original data type.It is carried out to the object after assignment
When HashMap structure is converted, the original data type of each object properties is converted to key=first by conversion transfer module 202
The form of value, this form are basic network data parameter data format of transfering, can by common data transmission segment identify with
Parsing.Conversion transfer module 202 again transmits the data of the key=value later.
The optimization transfer device of network request parameter provided in an embodiment of the present invention, by the way that corresponding execution module is arranged,
The assignment procedure of multiple network request parameters is safeguarded using object, and in parameter transmittance process, object is converted into
HashMap data type, can more convenient and fast maintenance and management network request parameter, and more effectively improve network request parameter
The reliability of transmitting.
Wherein optional, conversion transfer module is specifically used for, the data type of object properties in the object after reading assignment,
And it is based on data type and the corresponding default transformation rule of data type, using Java reflection mechanism, the object after assignment is turned
It is changed to HashMap categorical data.
Wherein optional, for the object after assignment, the value of data type is class, String, List, Map, set, number
One or more in group or custom object.
It is wherein optional, if the value of data type is custom object, converts transfer module and be specifically used for, using passing
Reduction method, all object properties of the object after obtaining assignment, and HashMap structure is carried out to each object properties respectively and is turned
It changes, obtains HashMap categorical data.
It is wherein optional, if the value of data type is class, converts transfer module and be specifically used for, reflects machine using Java
System obtains all object properties in parent and subclass respectively, and using the object properties in subclass, cover in parent with subclass
In the identical object properties of object properties;HashMap is carried out respectively to the object properties in the parent and subclass after covering
The conversion of structure obtains HashMap categorical data.
It is wherein optional, if the value of data type is List, set or array, converts transfer module and be specifically used for, point
All object properties in object after assignment are not converted to the character string of HashMap structure type, and using searching loop
Method splices the character string of all HashMap structure types using given character, and whole spliced character string is made
For HashMap categorical data;If the value of data type is Map, converts transfer module and be specifically used for, it directly will be after assignment
Object properties in object are added to HashMap categorical data;If the value of data type is String, transfer module is converted
It is specifically used for, obtains the attribute-name and attribute value of the object properties of String type respectively, and construct HashMap object, by this
Attribute-name and attribute value are added in HashMap object.
Further, on the basis of the various embodiments described above, assignment module is also used to, and unifies scoring criteria according to default,
Unify assignment to system is not carried out by the optional network request parameter of user's assignment;Wherein, it is preparatory for presetting unified scoring criteria
The scoring criteria to optional network request parameter established is set according to user.
Further, on the basis of the various embodiments described above, conversion transfer module is also used to, the object after reading assignment
After the step of data type of middle object properties, the assignment of reading object attribute, and based on data type and object properties
Whether the assignment of assignment, eavesdropping target's attribute is Java default value;And HashMap categorical data transmitted
After step, if the assignment of object properties is not Java default value, HashMap categorical data is parsed, otherwise, no
HashMap categorical data is parsed.
It is understood that can be by hardware processor (hardware processor) come real in the embodiment of the present invention
Each relative program module in the device of existing the various embodiments described above.Also, the optimization of each network request parameter of the embodiment of the present invention
Transfer device network request parameter in for realizing above-mentioned each method embodiment optimization transmitting when, the beneficial effect of generation with
Corresponding above-mentioned each method embodiment is identical, can refer to above-mentioned each method embodiment, details are not described herein again.
As the another aspect of the embodiment of the present invention, the present embodiment provides a kind of electronics according to the above embodiments and sets
It is standby, it is the entity structure schematic diagram of electronic equipment provided in an embodiment of the present invention, comprising: at least one processor with reference to Fig. 3
301, at least one processor 302, communication interface 303 and bus 304.
Wherein, memory 301, processor 302 and communication interface 303 complete mutual communication by bus 304, communicate
Interface 303 sends the information between terminal for the electronic equipment and target network required parameter and transmits;It is stored in memory 301
There is the computer program that can be run on processor 302, when processor 302 executes the computer program, realizes such as above-mentioned each reality
Apply the optimization transmission method of network request parameter described in example.
It is to be understood that including at least memory 301, processor 302, communication interface 303 and bus in the electronic equipment
304, and memory 301, processor 302 and communication interface 303 form mutual communication connection by bus 304, and can be complete
At mutual communication, the program as processor 302 reads the optimization transmission method of network request parameter from memory 301 refers to
Enable etc..In addition, communication interface 303 can also realize that the electronic equipment and target network required parameter send the communication between terminal
Connection, and achievable mutual information transmission, such as realize that the optimization of network request parameter is transmitted by communication interface 303.
When electronic equipment is run, processor 302 calls the program instruction in memory 301, real to execute above-mentioned each method
Apply method provided by example, for example, the custom object in the software development network architecture, and utilize target network request ginseng
Several pairs of objects carry out assignment;Object after assignment is converted into HashMap categorical data, and HashMap categorical data is carried out
Transmitting etc..
Program instruction in above-mentioned memory 301 can be realized and as independent by way of SFU software functional unit
Product when selling or using, can store in a computer readable storage medium.Alternatively, realizing that above-mentioned each method is implemented
This can be accomplished by hardware associated with program instructions for all or part of the steps of example, and program above-mentioned can store to be calculated in one
In machine read/write memory medium, when being executed, execution includes the steps that above-mentioned each method embodiment to the program;And storage above-mentioned
Medium includes: USB flash disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random
Access Memory, RAM), the various media that can store program code such as magnetic or disk.
The embodiment of the present invention provides a kind of non-transient computer readable storage medium also according to the various embodiments described above, this is non-temporarily
State computer-readable recording medium storage computer instruction, the computer instruction execute computer as described in the various embodiments described above
Network request parameter optimization transmission method, for example, the custom object in the software development network architecture, and utilize mesh
It marks network request parameter and assignment is carried out to object;Object after assignment is converted into HashMap categorical data, and to HashMap
Categorical data transmits etc..
Electronic equipment provided in an embodiment of the present invention and non-transient computer readable storage medium, by executing above-mentioned each reality
The optimization transmission method for applying network request parameter described in example safeguards the assignment mistake of multiple network request parameters using object
Journey, and in parameter transmittance process, object is converted into HashMap data type, it being capable of more convenient and fast maintenance and management network
Required parameter, and more effectively improve the reliability of network request parameter transmitting.
It is understood that the embodiment of device described above, electronic equipment and storage medium is only schematic
, wherein unit may or may not be physically separated as illustrated by the separation member, it can both be located at one
Place, or may be distributed on heterogeneous networks unit.Some or all of modules can be selected according to actual needs
To achieve the purpose of the solution of this embodiment.Those of ordinary skill in the art are without paying creative labor
To understand and implement.
By the description of embodiment of above, those skilled in the art is it will be clearly understood that each embodiment can borrow
Help software that the mode of required general hardware platform is added to realize, naturally it is also possible to pass through hardware.Based on this understanding, above-mentioned
Substantially the part that contributes to existing technology can be embodied in the form of software products technical solution in other words, the meter
Calculation machine software product may be stored in a computer readable storage medium, such as USB flash disk, mobile hard disk, ROM, RAM, magnetic disk or light
Disk etc., including some instructions, with so that a computer equipment (such as personal computer, server-side or network equipment etc.)
Execute method described in certain parts of above-mentioned each method embodiment or embodiment of the method.
In addition, those skilled in the art are it should be understood that in the application documents of the embodiment of the present invention, term
"include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that including a series of elements
Process, method, article or equipment not only include those elements, but also including other elements that are not explicitly listed, or
Person is to further include for elements inherent to such a process, method, article, or device.In the absence of more restrictions, by
The element that sentence "including a ..." limits, it is not excluded that in the process, method, article or apparatus that includes the element
There is also other identical elements.
In the specification of the embodiment of the present invention, numerous specific details are set forth.It should be understood, however, that the present invention is implemented
The embodiment of example can be practiced without these specific details.In some instances, it is not been shown in detail well known
Methods, structures and technologies, so as not to obscure the understanding of this specification.Similarly, it should be understood that in order to simplify implementation of the present invention
Example is open and helps to understand one or more of the various inventive aspects, above to the exemplary embodiment of the embodiment of the present invention
Description in, each feature of the embodiment of the present invention is grouped together into single embodiment, figure or descriptions thereof sometimes
In.
However, the disclosed method should not be interpreted as reflecting the following intention: i.e. the claimed invention is implemented
Example requires features more more than feature expressly recited in each claim.More precisely, such as claims institute
As reflection, inventive aspect is all features less than single embodiment disclosed above.Therefore, it then follows specific embodiment party
Thus claims of formula are expressly incorporated in the specific embodiment, wherein each claim itself is real as the present invention
Apply the separate embodiments of example.
Finally, it should be noted that above embodiments are only to illustrate the technical solution of the embodiment of the present invention, rather than it is limited
System;Although the embodiment of the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art it is understood that
It is still possible to modify the technical solutions described in the foregoing embodiments, or part of technical characteristic is carried out etc.
With replacement;And these are modified or replaceed, each embodiment skill of the embodiment of the present invention that it does not separate the essence of the corresponding technical solution
The spirit and scope of art scheme.
Claims (10)
1. a kind of optimization transmission method of network request parameter characterized by comprising
The custom object in the software development network architecture, and assignment is carried out to the object using target network required parameter;
Object after assignment is converted into HashMap categorical data, and the HashMap categorical data is transmitted.
2. the method according to claim 1, wherein the object by after assignment is converted to HashMap type
The step of data, specifically includes:
The data type of object properties in object after reading the assignment, and type and the data type based on the data
Object after the assignment is converted to the HashMap number of types using Java reflection mechanism by corresponding default transformation rule
According to.
3. according to the method described in claim 2, it is characterized in that, for the object after the assignment, the data type
Value is the one or more in class, String, List, Map, set, array or custom object.
4. according to the method described in claim 3, it is characterized in that, if the value of the data type be custom object,
The type based on the data and the corresponding default transformation rule of the data type, the object after the assignment is converted to
The step of HashMap categorical data, specifically includes:
Using recursive algorithm, all object properties of the object after obtaining the assignment, and respectively to each object properties into
The conversion of row HashMap structure obtains the HashMap categorical data.
5. according to the method described in claim 3, it is characterized in that, if the value of the data type is class, and including parent
And subclass, then type and the corresponding default transformation rule of the data type based on the data, after the assignment
Object is converted to the step of HashMap categorical data and specifically includes:
Using Java reflection mechanism, all objects in parent and subclass described in the object properties of class data type are obtained respectively
Attribute, and using the object properties in the subclass, it is identical right with the object properties in the subclass in the parent to cover
As attribute;
Object properties in parent and subclass after the covering are carried out with the conversion of HashMap structure respectively, described in acquisition
HashMap categorical data.
6. according to the method described in claim 3, it is characterized in that,
It, respectively will be all described in the object after the assignment if the value of the data type is List, set or array
Object properties are converted to the character string of HashMap structure type, and use searching loop method, by all HashMap structure types
Character string spliced using given character, and will whole spliced character string as the HashMap categorical data;
If the value of the data type is Map, directly the object properties in the object after the assignment are added to described
HashMap categorical data;
If the value of the data type is String, the attribute-name and attribute of the object properties of String type are obtained respectively
Value, and HashMap object is constructed, the attribute-name and attribute value are added in HashMap object.
7. according to the method described in claim 2, it is characterized in that, utilizing target network required parameter to the object described
Before the step of carrying out assignment, further includes: according to default unified scoring criteria, to not by the optional network request ginseng of user's assignment
Number carry out system unifies assignment;
Wherein, the default unified scoring criteria is to set the assignment to optional network request parameter established previously according to user
Standard.
8. the method according to the description of claim 7 is characterized in that the object properties in the object after the reading assignment
Data type the step of after, further includes:
The assignment of the object properties is read, and the assignment of type and the object properties based on the data, it is described right to monitor
As whether the assignment of attribute is Java default value;
After described the step of being transmitted to the HashMap categorical data, further includes: if the assignment of the object properties
It is not Java default value, then the HashMap categorical data is parsed, otherwise, not to the HashMap categorical data
It is parsed.
9. a kind of electronic equipment characterized by comprising at least one processor, at least one processor, communication interface and total
Line;
The memory, the processor and the communication interface complete mutual communication, the communication by the bus
Interface is also used to the information that the electronic equipment and target network required parameter are sent between terminal and transmits;
The computer program that can be run on the processor is stored in the memory, the processor executes the calculating
When machine program, the method as described in any in claim 1 to 8 is realized.
10. a kind of non-transient computer readable storage medium, which is characterized in that the non-transient computer readable storage medium is deposited
Computer instruction is stored up, the computer instruction makes the computer execute the method as described in any in claim 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811648338.2A CN109871203A (en) | 2018-12-30 | 2018-12-30 | Optimization transmission method, device and the electronic equipment of network request parameter |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811648338.2A CN109871203A (en) | 2018-12-30 | 2018-12-30 | Optimization transmission method, device and the electronic equipment of network request parameter |
Publications (1)
Publication Number | Publication Date |
---|---|
CN109871203A true CN109871203A (en) | 2019-06-11 |
Family
ID=66917338
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811648338.2A Pending CN109871203A (en) | 2018-12-30 | 2018-12-30 | Optimization transmission method, device and the electronic equipment of network request parameter |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109871203A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112540995A (en) * | 2020-11-11 | 2021-03-23 | 特劢丝软件科技(上海)有限公司 | Data updating method, electronic device and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106557531A (en) * | 2015-09-30 | 2017-04-05 | 伊姆西公司 | Labyrinth object is converted into planarizing data |
CN108492195A (en) * | 2018-03-08 | 2018-09-04 | 中国平安人寿保险股份有限公司 | Extensive method, equipment and storage medium are joined by a kind of entering for regulation engine packet |
-
2018
- 2018-12-30 CN CN201811648338.2A patent/CN109871203A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106557531A (en) * | 2015-09-30 | 2017-04-05 | 伊姆西公司 | Labyrinth object is converted into planarizing data |
CN108492195A (en) * | 2018-03-08 | 2018-09-04 | 中国平安人寿保险股份有限公司 | Extensive method, equipment and storage medium are joined by a kind of entering for regulation engine packet |
Non-Patent Citations (4)
Title |
---|
YJAFD: "利用Java中的反射将Pojo对象转换为HashMap", 《HTTPS://BLOG.CSDN.NET/YJAFD/ARTICLE/DETAILS/83293228》 * |
却把清梅嗅: "Android Retrofit2 Post 请求添加Json类型参数笔记", 《HTTPS://BLOG.CSDN.NET/MQ2553299/ARTICLE/DETAILS/70244505》 * |
沈军编著: "《大学程序设计基础系统化方法解析&Java描述》", 31 July 2015, 东南大学出版社 * |
王震江编著: "《XML程序设计》", 31 August 2015, 中国铁道出版社 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112540995A (en) * | 2020-11-11 | 2021-03-23 | 特劢丝软件科技(上海)有限公司 | Data updating method, electronic device and storage medium |
CN112540995B (en) * | 2020-11-11 | 2022-12-02 | 上海赛美特软件科技有限公司 | Data updating method, electronic device and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11847167B2 (en) | System and method for generation of chat bot system with integration elements augmenting natural language processing and native business rules | |
US8943076B2 (en) | System to automate mapping of variables between business process applications and method therefor | |
RU2648966C2 (en) | Apparatus and method for processing multiple open api | |
CN110276074B (en) | Distributed training method, device, equipment and storage medium for natural language processing | |
CA3128537A1 (en) | Interface message conversion method, device and system | |
US20130167109A1 (en) | System to Automate Development of System Integration Application Programs and Method Therefor | |
CN106874325B (en) | Data query method and device | |
CN102591724A (en) | Method and device for information interaction | |
CN109408247A (en) | Interaction data processing method and device | |
CN110166455A (en) | A kind of multi-operator platform data adaptation method and relevant device | |
CN113505520A (en) | Method, device and system for supporting heterogeneous federated learning | |
CN108984567A (en) | A kind of Service Data Management system and method | |
CN111026634A (en) | Interface automation test system, method, device and storage medium | |
CN110309269A (en) | Response process method and its system, computer system and computer-readable medium | |
CN110011875A (en) | Dial testing method, device, equipment and computer readable storage medium | |
CN107809332A (en) | Compound interface configures and compound interface call method, device | |
CN113726890B (en) | Federal prediction method and system for block chain data service | |
CN110795697A (en) | Logic expression obtaining method and device, storage medium and electronic device | |
CN110399306A (en) | Software module automated testing method and device | |
CN111145019A (en) | Method and system for acquiring data outside block chain | |
CN114466047B (en) | Method, platform, equipment and medium for conveniently accessing Internet of things equipment to Internet of things platform | |
CN116414370A (en) | Platform construction method and device based on low codes, medium and electronic equipment | |
CN108959294A (en) | A kind of method and apparatus accessing search engine | |
CN109871203A (en) | Optimization transmission method, device and the electronic equipment of network request parameter | |
CN112559124A (en) | Model management system and target operation instruction processing method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20190611 |