public interface JSONString
JSONString
interface allows a toJSONString()
method so that a class can change the behavior of
JSONObject.toString()
, JSONArray.toString()
,
and JSONWriter.value(
Object)
. The
toJSONString
method will be used instead of the default behavior
of using the Object's toString()
method and quoting the result.
If toJSONString()
returns null
, the class's
toString()
value will be quoted and used.
If a large value needs to be written, consider implementing
JSONAppendable
instead.
JSONAppendable
Modifier and Type | Method and Description |
---|---|
java.lang.String |
toJSONString()
The
toJSONString method allows a class to produce its own JSON
serialization. |
java.lang.String toJSONString()
toJSONString
method allows a class to produce its own JSON
serialization. If null
is returned, the class's
toString
method will be called, and the result will be
quoted and used.
If a runtime exception is thrown, this will be caught and propagated
as a JSONException
.
null
to indicate the toString
value should be used instead