Package io.javalin.plugin.json
Interface JsonMapper
-
public interface JsonMapper
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default <T> TfromJsonStream(InputStream json, Class<T> targetClass)If implemented, Javalin will use this method instead offromJsonString(String, Class)when mapping request bodies to JSON throughContext.bodyAsClass(Class).default <T> TfromJsonString(String json, Class<T> targetClass)IffromJsonStream(InputStream, Class)is not implemented, Javalin will use this method when mapping request bodies to JSON throughContext.bodyAsClass(Class).default InputStreamtoJsonStream(Object obj)Javalin uses this method forContext.json(Object), if called with useStreamingMapper = true.default StringtoJsonString(Object obj)Javalin uses this method forContext.json(Object), as well as the CookieStore class, WebSockets messaging, and JavalinVue.
-
-
-
Method Detail
-
toJsonString
@NotNull default String toJsonString(@NotNull Object obj)
Javalin uses this method forContext.json(Object), as well as the CookieStore class, WebSockets messaging, and JavalinVue.
-
toJsonStream
@NotNull default InputStream toJsonStream(@NotNull Object obj)
Javalin uses this method forContext.json(Object), if called with useStreamingMapper = true. When implementing this method, use (or look at) PipedStreamUtil to get an InputStream from an OutputStream.
-
fromJsonString
@NotNull default <T> T fromJsonString(@NotNull String json, @NotNull Class<T> targetClass)IffromJsonStream(InputStream, Class)is not implemented, Javalin will use this method when mapping request bodies to JSON throughContext.bodyAsClass(Class). Regardless of iffromJsonStream(InputStream, Class)is implemented, Javalin will use this method for Validation and for WebSocket messaging.
-
fromJsonStream
@NotNull default <T> T fromJsonStream(@NotNull InputStream json, @NotNull Class<T> targetClass)If implemented, Javalin will use this method instead offromJsonString(String, Class)when mapping request bodies to JSON throughContext.bodyAsClass(Class).
-
-