@Provider
@Produces(value="application/json")
public class JacksonJson
extends com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
implements javax.ws.rs.ext.ContextResolver<com.fasterxml.jackson.databind.ObjectMapper>
Modifier and Type | Class and Description |
---|---|
static class |
JacksonJson.JsonDateDeserializer
JsonDeserializer for deserializing ISO8601 formatted dates.
|
static class |
JacksonJson.JsonDateSerializer
JsonSerializer for serializing ISO8601 formatted dates.
|
static class |
JacksonJson.UserListDeserializer
Deserializer for the odd User instances in the "approved_by" array in the merge_request JSON.
|
static class |
JacksonJson.UserListSerializer
Serializer for the odd User instances in the "approved_by" array in the merge_request JSON.
|
DEFAULT_ANNOTATIONS
_jsonpFunctionName, _providers, BASIC_ANNOTATIONS, MIME_JAVASCRIPT, MIME_JAVASCRIPT_MS
_cfgCheckCanDeserialize, _cfgCheckCanSerialize, _cfgCustomUntouchables, _defaultReadView, _defaultWriteView, _jaxRSFeatures, _mapperConfig, _noContentExceptionRef, _readers, _unreadableClasses, _untouchables, _unwritableClasses, _writers, CLASS_NAME_NO_CONTENT_EXCEPTION, DEFAULT_UNREADABLES, DEFAULT_UNTOUCHABLES, DEFAULT_UNWRITABLES, HEADER_CONTENT_TYPE_OPTIONS, JAXRS_FEATURE_DEFAULTS, noContentExceptionSupplier
Constructor and Description |
---|
JacksonJson() |
Modifier and Type | Method and Description |
---|---|
com.fasterxml.jackson.databind.ObjectMapper |
getContext(Class<?> objectType) |
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
Gets the ObjectMapper contained by this instance.
|
<T> String |
marshal(T object)
Marshals the supplied object out as a formatted JSON string.
|
com.fasterxml.jackson.databind.JsonNode |
readTree(Reader reader)
Reads and parses the JSON data on the specified Reader instance to a JsonNode tree representation.
|
com.fasterxml.jackson.databind.JsonNode |
readTree(String postData)
Reads and parses the String containing JSON data and returns a JsonNode tree representation.
|
static com.fasterxml.jackson.databind.JsonNode |
toJsonNode(String jsonString)
Parse the provided String into a JsonNode instance.
|
static <T> String |
toJsonString(T object)
Gets a the supplied object output as a formatted JSON string.
|
<T> T |
unmarshal(Class<T> returnType,
com.fasterxml.jackson.databind.JsonNode tree)
Unmarshal the JsonNode (tree) to an instance of the provided class.
|
<T> T |
unmarshal(Class<T> returnType,
Reader reader)
Unmarshal the JSON data on the specified Reader instance to an instance of the provided class.
|
<T> T |
unmarshal(Class<T> returnType,
String postData)
Unmarshal the JSON data contained by the string and populate an instance of the provided returnType class.
|
<T> List<T> |
unmarshalList(Class<T> returnType,
Reader reader)
Unmarshal the JSON data on the specified Reader instance and populate a List of instances of the provided returnType class.
|
<T> List<T> |
unmarshalList(Class<T> returnType,
String postData)
Unmarshal the JSON data contained by the string and populate a List of instances of the provided returnType class.
|
<T> Map<String,T> |
unmarshalMap(Class<T> returnType,
Reader reader)
Unmarshal the JSON data on the specified Reader instance and populate a Map of String keys and values of the provided returnType class.
|
<T> Map<String,T> |
unmarshalMap(Class<T> returnType,
String jsonData)
Unmarshal the JSON data and populate a Map of String keys and values of the provided returnType class.
|
_configForReading, _configForWriting, _locateMapperViaProvider, hasMatchingMediaType, isJsonType, setJSONPFunctionName, version
_addSuperTypes, _configForReading, _configForWriting, _containedIn, _createGenerator, _createNoContentException, _createParser, _endpointForReading, _endpointForWriting, _findCustomUntouchable, _isIgnorableForReading, _isIgnorableForWriting, _isSpecialReadable, _modifyHeaders, addUntouchable, checkCanDeserialize, checkCanSerialize, configure, configure, configure, configure, configure, disable, disable, disable, disable, disable, disable, enable, enable, enable, enable, enable, enable, findEncoding, findSuperTypes, findSuperTypes, getSize, hasMatchingMediaTypeForReading, hasMatchingMediaTypeForWriting, isEnabled, isReadable, isWriteable, locateMapper, readFrom, removeUntouchable, setAnnotationsToUse, setDefaultReadView, setDefaultView, setDefaultWriteView, setMapper, writeTo
public com.fasterxml.jackson.databind.ObjectMapper getContext(Class<?> objectType)
getContext
in interface javax.ws.rs.ext.ContextResolver<com.fasterxml.jackson.databind.ObjectMapper>
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public com.fasterxml.jackson.databind.JsonNode readTree(String postData) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
postData
- a String holding the POST datacom.fasterxml.jackson.core.JsonParseException
- when an error occurs parsing the provided JSONcom.fasterxml.jackson.databind.JsonMappingException
- if a JSON error occursIOException
- if an error occurs reading the JSON datapublic com.fasterxml.jackson.databind.JsonNode readTree(Reader reader) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
reader
- the Reader instance that contains the JSON datacom.fasterxml.jackson.core.JsonParseException
- when an error occurs parsing the provided JSONcom.fasterxml.jackson.databind.JsonMappingException
- if a JSON error occursIOException
- if an error occurs reading the JSON datapublic <T> T unmarshal(Class<T> returnType, com.fasterxml.jackson.databind.JsonNode tree) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T
- the generics type for the return valuereturnType
- an instance of this type class will be returnedtree
- the JsonNode instance that contains the JSON datacom.fasterxml.jackson.core.JsonParseException
- when an error occurs parsing the provided JSONcom.fasterxml.jackson.databind.JsonMappingException
- if a JSON error occursIOException
- if an error occurs reading the JSON datapublic <T> T unmarshal(Class<T> returnType, Reader reader) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T
- the generics type for the return valuereturnType
- an instance of this type class will be returnedreader
- the Reader instance that contains the JSON datacom.fasterxml.jackson.core.JsonParseException
- when an error occurs parsing the provided JSONcom.fasterxml.jackson.databind.JsonMappingException
- if a JSON error occursIOException
- if an error occurs reading the JSON datapublic <T> T unmarshal(Class<T> returnType, String postData) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T
- the generics type for the return valuereturnType
- an instance of this type class will be returnedpostData
- a String holding the POST datacom.fasterxml.jackson.core.JsonParseException
- when an error occurs parsing the provided JSONcom.fasterxml.jackson.databind.JsonMappingException
- if a JSON error occursIOException
- if an error occurs reading the JSON datapublic <T> List<T> unmarshalList(Class<T> returnType, Reader reader) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T
- the generics type for the ListreturnType
- an instance of this type class will be contained in the returned Listreader
- the Reader instance that contains the JSON datacom.fasterxml.jackson.core.JsonParseException
- when an error occurs parsing the provided JSONcom.fasterxml.jackson.databind.JsonMappingException
- if a JSON error occursIOException
- if an error occurs reading the JSON datapublic <T> List<T> unmarshalList(Class<T> returnType, String postData) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T
- the generics type for the ListreturnType
- an instance of this type class will be contained in the returned ListpostData
- a String holding the POST datacom.fasterxml.jackson.core.JsonParseException
- when an error occurs parsing the provided JSONcom.fasterxml.jackson.databind.JsonMappingException
- if a JSON error occursIOException
- if an error occurs reading the JSON datapublic <T> Map<String,T> unmarshalMap(Class<T> returnType, Reader reader) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T
- the generics type for the Map valuereturnType
- an instance of this type class will be contained the values of the Mapreader
- the Reader instance that contains the JSON datacom.fasterxml.jackson.core.JsonParseException
- when an error occurs parsing the provided JSONcom.fasterxml.jackson.databind.JsonMappingException
- if a JSON error occursIOException
- if an error occurs reading the JSON datapublic <T> Map<String,T> unmarshalMap(Class<T> returnType, String jsonData) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
T
- the generics type for the Map valuereturnType
- an instance of this type class will be contained the values of the MapjsonData
- the String containing the JSON datacom.fasterxml.jackson.core.JsonParseException
- when an error occurs parsing the provided JSONcom.fasterxml.jackson.databind.JsonMappingException
- if a JSON error occursIOException
- if an error occurs reading the JSON datapublic <T> String marshal(T object)
T
- the generics type for the provided objectobject
- the object to output as a JSON stringpublic static <T> String toJsonString(T object)
T
- the generics type for the provided objectobject
- the object to output as a JSON stringpublic static com.fasterxml.jackson.databind.JsonNode toJsonNode(String jsonString) throws IOException
jsonString
- a String containing JSON to parseIOException
- if any IO error occursCopyright © 2019. All rights reserved.