|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.joda.beans.ser.json.JodaBeanSimpleJsonWriter
public class JodaBeanSimpleJsonWriter
Provides the ability for a Joda-Bean to be written to a simple JSON format.
This class contains mutable state and cannot be used from multiple threads. A new instance must be created for each message.
The JSON format used here is natural, with no meta-data. As such, it may not be possible to write some objects or read the JSON data back in.
Beans are output using JSON objects where the key is the property name.
Most simple types, defined by Joda-Convert, are output as JSON strings.
Null values are generally omitted, but where included are sent as 'null'.
Boolean values are sent as 'true' and 'false'.
Numeric values are sent as JSON numbers.
Maps must have a key that can be converted to a string by Joda-Convert.
The property type needs to be known when writing/reading - properties, or
list/map entries, that are defined as Object are unlikely to work well.
Collections are output using JSON arrays. Maps as JSON objects. Multisets are output as a map of value to count.
| Constructor Summary | |
|---|---|
JodaBeanSimpleJsonWriter(JodaBeanSer settings)
Creates an instance. |
|
| Method Summary | |
|---|---|
String |
write(Bean bean)
Writes the bean to a string. |
void |
write(Bean bean,
Appendable output)
Writes the bean to the Appendable. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JodaBeanSimpleJsonWriter(JodaBeanSer settings)
settings - the settings to use, not null| Method Detail |
|---|
public String write(Bean bean)
bean - the bean to output, not null
public void write(Bean bean,
Appendable output)
throws IOException
Appendable.
The type of the bean will be set in the message.
bean - the bean to output, not nulloutput - the output appendable, not null
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||