public class JSONCodec
extends java.lang.Object
Constructor and Description |
---|
JSONCodec()
Constructor using the default configuration.
|
JSONCodec(boolean ignoreNull)
Deprecated.
use
JSONCodec(JSONCodecConfiguration) instead. |
JSONCodec(boolean ignoreNull,
boolean ignoreMissingFields)
Deprecated.
use
JSONCodec(JSONCodecConfiguration) instead. |
JSONCodec(java.nio.charset.Charset charset,
boolean ignoreNull)
Deprecated.
use
JSONCodec(JSONCodecConfiguration) instead. |
JSONCodec(java.nio.charset.Charset charset,
boolean ignoreNull,
boolean ignoreMissingFields)
Deprecated.
use
JSONCodec(JSONCodecConfiguration) instead. |
JSONCodec(JSONCodecConfiguration config)
Constructor using a specific configuration.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
decodeObject(java.io.InputStream inputStream,
java.lang.Class<?> target)
decodes the given json string from input stream into an object of the given target type.
|
java.lang.Object |
decodeObject(java.io.InputStream inputStream,
java.lang.Object target)
decodes the given json string from input stream into the given target object.
|
java.lang.Object |
decodeObject(JSONObject json,
java.lang.Class<?> clazz) |
<T> T |
decodeObject(JSONObject json,
T target) |
java.lang.Object |
decodeObject(java.lang.String jsonString,
java.lang.Class<?> type)
decodes the given json string into an object of the given target type.
|
java.lang.Object |
decodeObject(java.lang.String jsonString,
java.lang.Object target)
decodes the given json string into the given target object.
|
java.lang.String |
encodeObject(java.lang.Object o) |
void |
encodeObject(java.lang.Object o,
java.io.OutputStream out) |
java.lang.Object |
encodeObjectJSON(java.lang.Object o)
Encodes the given object into a JSONObject or JSONArray, depending on the given
object.
|
java.lang.Object |
encodeObjectJSON(java.lang.Object o,
java.lang.Class<?> referenceType)
returns a JSONObject or JSONArray depending on the given
object o to be encoded.
|
static JSONStringFormatter |
getDefaultStringFormatter()
Returns a string formatter with the default configuration used to encode
Java objects to JSON.
|
static void |
setDefaultConfiguration(JSONCodecConfiguration config)
This method allows to change the default behaviour of JSONCodecs.
|
public JSONCodec()
JSONCodecConfiguration}
,
#setDefaultConfiguration(JSONCodecConfiguration)}
public JSONCodec(JSONCodecConfiguration config)
config
- Configuration to be used by the codec.public JSONCodec(java.nio.charset.Charset charset, boolean ignoreNull, boolean ignoreMissingFields)
JSONCodec(JSONCodecConfiguration)
instead.public JSONCodec(boolean ignoreNull, boolean ignoreMissingFields)
JSONCodec(JSONCodecConfiguration)
instead.public JSONCodec(java.nio.charset.Charset charset, boolean ignoreNull)
JSONCodec(JSONCodecConfiguration)
instead.public JSONCodec(boolean ignoreNull)
JSONCodec(JSONCodecConfiguration)
instead.public static void setDefaultConfiguration(JSONCodecConfiguration config)
config
- The new default configuration to be used by all subsequently created JSONCodec instances.public static JSONStringFormatter getDefaultStringFormatter()
public java.lang.Object decodeObject(java.lang.String jsonString, java.lang.Object target) throws JSONCodecException
JSONCodecException
public java.lang.Object decodeObject(java.io.InputStream inputStream, java.lang.Object target) throws JSONCodecException
JSONCodecException
public java.lang.Object decodeObject(java.io.InputStream inputStream, java.lang.Class<?> target) throws JSONCodecException
JSONCodecException
public java.lang.Object decodeObject(java.lang.String jsonString, java.lang.Class<?> type) throws JSONCodecException
JSONCodecException
public java.lang.Object decodeObject(JSONObject json, java.lang.Class<?> clazz) throws JSONCodecException
JSONCodecException
public <T> T decodeObject(JSONObject json, T target) throws JSONCodecException
JSONCodecException
public java.lang.String encodeObject(java.lang.Object o) throws JSONCodecException
JSONCodecException
public void encodeObject(java.lang.Object o, java.io.OutputStream out) throws JSONCodecException
JSONCodecException
public java.lang.Object encodeObjectJSON(java.lang.Object o, java.lang.Class<?> referenceType) throws JSONCodecException
o
- Object to be encoded.referenceType
- Class of the object or some subclass, in case you want just a particular subset of the membersJSONCodecException
public java.lang.Object encodeObjectJSON(java.lang.Object o) throws JSONCodecException
o
- JSONCodecException