Motivation
To completely decouple Jooby applications from specific JSON engines (Jackson, Gson, Avaje, etc.), we need a generic JSON abstraction.
@FunctionalInterface
public interface JsonEncoder {
String encode(Object value);
}
@FunctionalInterface
public interface JsonDecoder {
// Core contract for implementors (handles complex generics)
<T> T decode(String json, java.lang.reflect.Type type);
// Convenience method for users
@SuppressWarnings("unchecked")
default <T> T decode(String json, Class<T> type) {
return decode(json, (java.lang.reflect.Type) type);
}
}
// The unified contract for dependency injection
public interface JsonCodec extends JsonEncoder, JsonDecoder {
}
Module Implementors:
- jackson
- avaje-json
- gson
- yasson
Motivation
To completely decouple Jooby applications from specific JSON engines (Jackson, Gson, Avaje, etc.), we need a generic JSON abstraction.
Module Implementors: