Class JacksonJson

java.lang.Object
org.glassfish.jersey.jackson.internal.jackson.jaxrs.base.ProviderBase<org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider,com.fasterxml.jackson.databind.ObjectMapper,org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JsonEndpointConfig,org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JsonMapperConfigurator>
org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider
org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider
org.gitlab4j.api.utils.JacksonJson
All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned, javax.ws.rs.ext.ContextResolver<com.fasterxml.jackson.databind.ObjectMapper>, javax.ws.rs.ext.MessageBodyReader<Object>, javax.ws.rs.ext.MessageBodyWriter<Object>

@Produces("application/json") public class JacksonJson extends org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider implements javax.ws.rs.ext.ContextResolver<com.fasterxml.jackson.databind.ObjectMapper>
Jackson JSON Configuration and utility class.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    JsonSerializer for serializing dates s yyyy-mm-dd in UTC timezone.
    static class 
    JsonDeserializer for deserializing ISO8601 formatted dates.
    static class 
    JsonSerializer for serializing ISO8601 formatted dates.
    static class 
    Deserializer for the odd User instances in the "approved_by" array in the merge_request JSON.
    static class 
    Serializer for the odd User instances in the "approved_by" array in the merge_request JSON.
  • Field Summary

    Fields inherited from class org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider

    DEFAULT_ANNOTATIONS

    Fields inherited from class org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider

    _jsonpFunctionName, _providers, BASIC_ANNOTATIONS, MIME_JAVASCRIPT, MIME_JAVASCRIPT_MS

    Fields inherited from class org.glassfish.jersey.jackson.internal.jackson.jaxrs.base.ProviderBase

    _cfgCheckCanDeserialize, _cfgCheckCanSerialize, _cfgCustomUntouchables, _defaultReadView, _defaultWriteView, _jaxRSFeatures, _mapperConfig, _noContentExceptionRef, _readers, _unreadableClasses, _untouchables, _unwritableClasses, _writers, DEFAULT_UNREADABLES, DEFAULT_UNTOUCHABLES, DEFAULT_UNWRITABLES, HEADER_CONTENT_TYPE_OPTIONS, JAXRS_FEATURE_DEFAULTS
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.fasterxml.jackson.databind.ObjectMapper
    getContext(Class<?> objectType)
     
    com.fasterxml.jackson.databind.ObjectMapper
    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.

    Methods inherited from class org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider

    _configForReading, _configForWriting, _locateMapperViaProvider, hasMatchingMediaType, setJSONPFunctionName, version

    Methods inherited from class org.glassfish.jersey.jackson.internal.jackson.jaxrs.base.ProviderBase

    _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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JacksonJson

      public JacksonJson()
  • Method Details

    • getContext

      public com.fasterxml.jackson.databind.ObjectMapper getContext(Class<?> objectType)
      Specified by:
      getContext in interface javax.ws.rs.ext.ContextResolver<com.fasterxml.jackson.databind.ObjectMapper>
    • getObjectMapper

      public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      Gets the ObjectMapper contained by this instance.
      Returns:
      the ObjectMapper contained by this instance
    • readTree

      public com.fasterxml.jackson.databind.JsonNode readTree(String postData) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Reads and parses the String containing JSON data and returns a JsonNode tree representation.
      Parameters:
      postData - a String holding the POST data
      Returns:
      a JsonNode instance containing the parsed JSON
      Throws:
      com.fasterxml.jackson.core.JsonParseException - when an error occurs parsing the provided JSON
      com.fasterxml.jackson.databind.JsonMappingException - if a JSON error occurs
      IOException - if an error occurs reading the JSON data
    • readTree

      public com.fasterxml.jackson.databind.JsonNode readTree(Reader reader) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Reads and parses the JSON data on the specified Reader instance to a JsonNode tree representation.
      Parameters:
      reader - the Reader instance that contains the JSON data
      Returns:
      a JsonNode instance containing the parsed JSON
      Throws:
      com.fasterxml.jackson.core.JsonParseException - when an error occurs parsing the provided JSON
      com.fasterxml.jackson.databind.JsonMappingException - if a JSON error occurs
      IOException - if an error occurs reading the JSON data
    • unmarshal

      public <T> T unmarshal(Class<T> returnType, com.fasterxml.jackson.databind.JsonNode tree) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Unmarshal the JsonNode (tree) to an instance of the provided class.
      Type Parameters:
      T - the generics type for the return value
      Parameters:
      returnType - an instance of this type class will be returned
      tree - the JsonNode instance that contains the JSON data
      Returns:
      an instance of the provided class containing the data from the tree
      Throws:
      com.fasterxml.jackson.core.JsonParseException - when an error occurs parsing the provided JSON
      com.fasterxml.jackson.databind.JsonMappingException - if a JSON error occurs
      IOException - if an error occurs reading the JSON data
    • unmarshal

      public <T> T unmarshal(Class<T> returnType, Reader reader) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Unmarshal the JSON data on the specified Reader instance to an instance of the provided class.
      Type Parameters:
      T - the generics type for the return value
      Parameters:
      returnType - an instance of this type class will be returned
      reader - the Reader instance that contains the JSON data
      Returns:
      an instance of the provided class containing the parsed data from the Reader
      Throws:
      com.fasterxml.jackson.core.JsonParseException - when an error occurs parsing the provided JSON
      com.fasterxml.jackson.databind.JsonMappingException - if a JSON error occurs
      IOException - if an error occurs reading the JSON data
    • unmarshal

      public <T> T unmarshal(Class<T> returnType, String postData) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Unmarshal the JSON data contained by the string and populate an instance of the provided returnType class.
      Type Parameters:
      T - the generics type for the return value
      Parameters:
      returnType - an instance of this type class will be returned
      postData - a String holding the POST data
      Returns:
      an instance of the provided class containing the parsed data from the string
      Throws:
      com.fasterxml.jackson.core.JsonParseException - when an error occurs parsing the provided JSON
      com.fasterxml.jackson.databind.JsonMappingException - if a JSON error occurs
      IOException - if an error occurs reading the JSON data
    • unmarshalList

      public <T> List<T> unmarshalList(Class<T> returnType, Reader reader) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Unmarshal the JSON data on the specified Reader instance and populate a List of instances of the provided returnType class.
      Type Parameters:
      T - the generics type for the List
      Parameters:
      returnType - an instance of this type class will be contained in the returned List
      reader - the Reader instance that contains the JSON data
      Returns:
      a List of the provided class containing the parsed data from the Reader
      Throws:
      com.fasterxml.jackson.core.JsonParseException - when an error occurs parsing the provided JSON
      com.fasterxml.jackson.databind.JsonMappingException - if a JSON error occurs
      IOException - if an error occurs reading the JSON data
    • unmarshalList

      public <T> List<T> unmarshalList(Class<T> returnType, String postData) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Unmarshal the JSON data contained by the string and populate a List of instances of the provided returnType class.
      Type Parameters:
      T - the generics type for the List
      Parameters:
      returnType - an instance of this type class will be contained in the returned List
      postData - a String holding the POST data
      Returns:
      a List of the provided class containing the parsed data from the string
      Throws:
      com.fasterxml.jackson.core.JsonParseException - when an error occurs parsing the provided JSON
      com.fasterxml.jackson.databind.JsonMappingException - if a JSON error occurs
      IOException - if an error occurs reading the JSON data
    • unmarshalMap

      public <T> Map<String,T> unmarshalMap(Class<T> returnType, Reader reader) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Unmarshal the JSON data on the specified Reader instance and populate a Map of String keys and values of the provided returnType class.
      Type Parameters:
      T - the generics type for the Map value
      Parameters:
      returnType - an instance of this type class will be contained the values of the Map
      reader - the Reader instance that contains the JSON data
      Returns:
      a Map containing the parsed data from the Reader
      Throws:
      com.fasterxml.jackson.core.JsonParseException - when an error occurs parsing the provided JSON
      com.fasterxml.jackson.databind.JsonMappingException - if a JSON error occurs
      IOException - if an error occurs reading the JSON data
    • unmarshalMap

      public <T> Map<String,T> unmarshalMap(Class<T> returnType, String jsonData) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException
      Unmarshal the JSON data and populate a Map of String keys and values of the provided returnType class.
      Type Parameters:
      T - the generics type for the Map value
      Parameters:
      returnType - an instance of this type class will be contained the values of the Map
      jsonData - the String containing the JSON data
      Returns:
      a Map containing the parsed data from the String
      Throws:
      com.fasterxml.jackson.core.JsonParseException - when an error occurs parsing the provided JSON
      com.fasterxml.jackson.databind.JsonMappingException - if a JSON error occurs
      IOException - if an error occurs reading the JSON data
    • marshal

      public <T> String marshal(T object)
      Marshals the supplied object out as a formatted JSON string.
      Type Parameters:
      T - the generics type for the provided object
      Parameters:
      object - the object to output as a JSON string
      Returns:
      a String containing the JSON for the specified object
    • toJsonString

      public static <T> String toJsonString(T object)
      Gets a the supplied object output as a formatted JSON string. Null properties will result in the value of the property being null. This is meant to be used for toString() implementations of GitLab4J classes.
      Type Parameters:
      T - the generics type for the provided object
      Parameters:
      object - the object to output as a JSON string
      Returns:
      a String containing the JSON for the specified object
    • toJsonNode

      public static com.fasterxml.jackson.databind.JsonNode toJsonNode(String jsonString) throws IOException
      Parse the provided String into a JsonNode instance.
      Parameters:
      jsonString - a String containing JSON to parse
      Returns:
      a JsonNode with the String parsed into a JSON tree
      Throws:
      IOException - if any IO error occurs