T - The typepublic interface JsonWriter<T> extends HasModelWriteHandler<T>
The setup of JsonWriter is inspired by the UiBinder and is typically specified as an inner class:
pubilc RunnableMessageContext
{
interface Writer extends JsonWriter<RunnableMessageContext> {}
public static final Writer JSON_WRITER = GWT.create(Writer.class);
// The properties of this POJO
}
JSON can then be generated by calling
RunnableMessageContext rmc = new RunnableMessageContext(); ... String json = RunnableMessageContext.JSON_WRITER.toJson(rmc);
| Modifier and Type | Method and Description |
|---|---|
String |
toJson(List<T> models,
String arrayKey)
Generates JSON data for the list of Ts according to the annotated
properties in T.
|
String |
toJson(T model)
Generates JSON data for T according to the annotated properties in T.
|
addModelWriteHandlerString toJson(List<T> models, String arrayKey)
List<RunnableMessageContext> rmcs = ...;
String json = RunnableMessageContext.JSON_WRITER.toJson(rmcs, "data");
// json will be somethig like {"data":[...]}
models - the list of Ts to serialize to JSON. May be null.arrayKey - the array keynull if
models and/or arrayKey is null.Copyright © 2012 Harald Pehl. All Rights Reserved.