@Documented @Target(value=PARAMETER) @Retention(value=RUNTIME) public @interface QueryMap
Both keys and values are converted to strings using String.valueOf(Object)
. Values are
URL encoded and null
will not include the query parameter in the URL. null
keys
are not allowed.
Simple Example:
@GET("/search") void list(@QueryMap Map<String, String> filters);Calling with
foo.list(ImmutableMap.of("foo", "bar", "kit", "kat"))
yields
/search?foo=bar&kit=kat
.
Map keys representing the parameter names are not URL encoded. Specify
encodeNames=true
to change this behavior.
@GET("/search") void list(@QueryMap(encodeNames=true) Map<String, String> filters);Calling with
foo.list(ImmutableMap.of("foo+bar", "foo+bar"))
yields
/search?foo%2Bbar=foo
.
Map values representing parameter values are URL encoded by default. Specify
encodeValues=false
to change this behavior.
@GET("/search") void list(@QueryMap(encodeValues=false) Map<String, String> filters);Calling with
foo.list(ImmutableMap.of("foo", "foo+foo"))
yields
/search?foo=foo%2Bbar
.Query
Modifier and Type | Optional Element and Description |
---|---|
boolean |
encodeNames
Specifies whether parameter names (keys in the map) are URL encoded.
|
boolean |
encodeValues
Specifies whether parameter values (values in the map) are URL encoded.
|
Copyright © 2015 Square, Inc.. All Rights Reserved.