public interface JsonMapper
| Modifier and Type | Method and Description |
|---|---|
default <T> T |
fromJsonStream(InputStream json,
Class<T> targetClass)
If implemented, Javalin will use this method instead of
fromJsonString(String, Class)
when mapping request bodies to JSON through Context.bodyAsClass(Class). |
default <T> T |
fromJsonString(String json,
Class<T> targetClass)
If
fromJsonStream(InputStream, Class) is not implemented, Javalin will use this method
when mapping request bodies to JSON through Context.bodyAsClass(Class). |
default InputStream |
toJsonStream(Object obj)
Javalin uses this method for
io.javalin.http.Context#json(Object, boolean),
if called with useStreamingMapper = true. |
default String |
toJsonString(Object obj)
Javalin uses this method for
Context.json(Object),
as well as the CookieStore class, WebSockets messaging, and JavalinVue. |
@NotNull default String toJsonString(@NotNull Object obj)
Context.json(Object),
as well as the CookieStore class, WebSockets messaging, and JavalinVue.@NotNull default InputStream toJsonStream(@NotNull Object obj)
io.javalin.http.Context#json(Object, boolean),
if called with useStreamingMapper = true.
When implementing this method, use (or look at) PipedStreamUtil to get
an InputStream from an OutputStream.@NotNull
default <T> T fromJsonString(@NotNull
String json,
@NotNull
Class<T> targetClass)
fromJsonStream(InputStream, Class) is not implemented, Javalin will use this method
when mapping request bodies to JSON through Context.bodyAsClass(Class).
Regardless of if fromJsonStream(InputStream, Class) is implemented, Javalin will
use this method for Validation and for WebSocket messaging.@NotNull
default <T> T fromJsonStream(@NotNull
InputStream json,
@NotNull
Class<T> targetClass)
fromJsonString(String, Class)
when mapping request bodies to JSON through Context.bodyAsClass(Class).Copyright © 2022. All rights reserved.