public class Json
extends java.lang.Object
| Constructor and Description |
|---|
Json() |
| Modifier and Type | Method and Description |
|---|---|
static com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper() |
static <R> R |
parseBodyToObject(java.lang.String body,
java.lang.String canonicalResponseType) |
static <B> java.util.Map<java.lang.String,HttpParam> |
toFormUrlEncoded(B body) |
static <B> java.lang.String |
writeBodyToString(B body,
java.lang.String canonicalRequestType)
Write the body to a JSON string.
|
public static <B> java.lang.String writeBodyToString(B body,
java.lang.String canonicalRequestType)
The main reason why we need the canonical form of the request type to serialize the body is in cases where Java type erasure hides access to the Json annotations of our transfer objects.
Examples of such type erasure are cases where types in a hierarchy are put inside a java.util.List<B>. Then, the type of
<B> is hidden in java.util.List<?>, which hides the @JsonTypeInfo annotations for the objectmapper so that all type info
disappears form the resulting JSON objects.
B - The type of the body.body - The actual body.canonicalRequestType - The canonical form of the request body.public static <B> java.util.Map<java.lang.String,HttpParam> toFormUrlEncoded(B body)
public static <R> R parseBodyToObject(java.lang.String body,
java.lang.String canonicalResponseType)
public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()