Class JacksonBodyAdapter

java.lang.Object
io.avaje.http.client.JacksonBodyAdapter
All Implemented Interfaces:
BodyAdapter

public final class JacksonBodyAdapter extends Object implements BodyAdapter
Jackson BodyAdapter to read and write beans as JSON.


   HttpClient.builder()
       .baseUrl(baseUrl)
       .bodyAdapter(new JacksonBodyAdapter())
       .build();

 
  • Constructor Details

    • JacksonBodyAdapter

      public JacksonBodyAdapter(com.fasterxml.jackson.databind.ObjectMapper mapper)
      Create passing the ObjectMapper to use.
    • JacksonBodyAdapter

      public JacksonBodyAdapter()
      Create with a ObjectMapper that allows unknown properties and inclusion non empty.
  • Method Details

    • beanWriter

      public <T> BodyWriter<T> beanWriter(Class<?> cls)
      Description copied from interface: BodyAdapter
      Return a BodyWriter to write beans of this type as request content.
      Specified by:
      beanWriter in interface BodyAdapter
      Parameters:
      cls - The type of the bean this writer is for
    • beanReader

      public <T> BodyReader<T> beanReader(Class<T> cls)
      Description copied from interface: BodyAdapter
      Return a BodyReader to read response content and convert to a bean.
      Specified by:
      beanReader in interface BodyAdapter
      Parameters:
      cls - The bean type to convert the content to.
    • listReader

      public <T> BodyReader<List<T>> listReader(Class<T> cls)
      Description copied from interface: BodyAdapter
      Return a BodyReader to read response content and convert to a list of beans.
      Specified by:
      listReader in interface BodyAdapter
      Parameters:
      cls - The bean type to convert the content to.