Class PojoMapper


  • public class PojoMapper
    extends Object
    Convert from JSON structures to regular Java objects. Supports primitive numbers (byte, short, int, long, float, double, BigDecimal, BigInteger), simple values (for String, character, Instant, LocalDate, ZonedDateTime, OffsetDateTime, UUID, URL, URI and InetAddress), Enums, Collections, Maps, Streams and Java beans. You can even add your own converters.

    Usage:

     PojoMapper pojoMapper = new PojoMapper();
     pojoMapper.addObjectMapper(MyClass.class, (json, mapper) -> new MyClass());
     MyClass o = pojoMapper.map(json, MyClass.class);
     
    • Constructor Detail

      • PojoMapper

        public PojoMapper()
    • Method Detail

      • map

        public <T> T map​(javax.json.JsonValue json,
                         Class<T> targetType)
        Map from json to a object of the specified target class
      • read

        public Object read​(Reader reader,
                           Type returnType)
        Read from json string to a object of the specified target type
      • map

        public <T> T map​(javax.json.JsonValue json,
                         Type targetType)
        Map from json to a object of the specified target type
      • newInstance

        protected Object newInstance​(Type targetType)
      • writeFields

        public <T> T writeFields​(javax.json.JsonObject json,
                                 T o)
      • getterName

        protected String getterName​(String fieldName)
      • setterName

        protected String setterName​(String fieldName)
      • setterNameCamelCase

        protected String setterNameCamelCase​(String fieldName)
      • fromUnderscoreToCamelCase

        protected String fromUnderscoreToCamelCase​(String key)
      • rejectUnknownFields

        public PojoMapper rejectUnknownFields()
      • getClassType

        protected Class<?> getClassType​(Type type)