public class JSON extends Object implements com.fasterxml.jackson.core.Versioned
Note that instances are fully immutable, and thereby thread-safe.
Modifier and Type | Class and Description |
---|---|
static class |
JSON.Feature
Simple on/off (enabled/disabled) features for
JSON ; used for simple configuration
aspects. |
Modifier and Type | Field and Description |
---|---|
protected int |
_features |
protected com.fasterxml.jackson.core.JsonFactory |
_jsonFactory
Underlying JSON factory used for creating Streaming parsers and
generators.
|
protected com.fasterxml.jackson.core.PrettyPrinter |
_prettyPrinter |
protected JSONReader |
_reader
Blueprint instance of the reader to use for reading JSON as simple
Objects.
|
protected com.fasterxml.jackson.core.TreeCodec |
_treeCodec
Optional handler for
TreeNode values: if defined, we can
read and write TreeNode instances that codec supports. |
protected JSONWriter |
_writer
Blueprint isntance of the writer to use for writing JSON given
simple Objects.
|
static JSON |
std
Singleton instance with standard, default configuration.
|
Modifier | Constructor and Description |
---|---|
|
JSON() |
protected |
JSON(int features,
com.fasterxml.jackson.core.JsonFactory jsonF,
com.fasterxml.jackson.core.TreeCodec trees) |
protected |
JSON(int features,
com.fasterxml.jackson.core.JsonFactory jsonF,
com.fasterxml.jackson.core.TreeCodec trees,
JSONReader r,
JSONWriter w,
com.fasterxml.jackson.core.PrettyPrinter pp) |
Modifier and Type | Method and Description |
---|---|
protected void |
_close(Closeable cl) |
protected void |
_close(Closeable cl,
Exception e) |
protected com.fasterxml.jackson.core.JsonGenerator |
_config(com.fasterxml.jackson.core.JsonGenerator jgen) |
protected com.fasterxml.jackson.core.JsonParser |
_config(com.fasterxml.jackson.core.JsonParser jp) |
protected JSONReader |
_defaultReader(int features,
com.fasterxml.jackson.core.TreeCodec tc) |
protected JSONWriter |
_defaultWriter(int features,
com.fasterxml.jackson.core.TreeCodec tc) |
protected com.fasterxml.jackson.core.JsonParser |
_initForReading(com.fasterxml.jackson.core.JsonParser jp) |
protected com.fasterxml.jackson.core.JsonParser |
_parser(Object source) |
protected JSONReader |
_readerForOperation(com.fasterxml.jackson.core.JsonParser jp) |
protected JSON |
_with(int features)
Internal mutant factory method used for constructing
|
protected JSON |
_with(int features,
com.fasterxml.jackson.core.JsonFactory jsonF,
com.fasterxml.jackson.core.TreeCodec trees,
JSONReader reader,
JSONWriter writer,
com.fasterxml.jackson.core.PrettyPrinter pp) |
protected void |
_writeAndClose(Object value,
com.fasterxml.jackson.core.JsonGenerator jgen) |
protected JSONWriter |
_writerForOperation(com.fasterxml.jackson.core.JsonGenerator jgen) |
Object |
anyFrom(Object source)
|
Object[] |
arrayFrom(Object source) |
<T> T[] |
arrayOfFrom(Class<T> type,
Object source) |
byte[] |
asBytes(Object value) |
com.fasterxml.jackson.core.ObjectCodec |
asCodec()
Convenience method for constructing an adapter that uses this
instance as a
ObjectCodec |
String |
asString(Object value) |
<T> T |
beanFrom(Class<T> type,
Object source) |
JSONComposer<byte[]> |
composeBytes() |
<C extends Collection<Object>> |
composeCollection(C collection) |
CollectionComposer<?,List<Object>> |
composeList() |
MapComposer<?> |
composeMap() |
MapComposer<?> |
composeMap(Map<String,Object> map) |
JSONComposer<String> |
composeString() |
JSONComposer<OutputStream> |
composeTo(File f) |
JSONComposer<OutputStream> |
composeTo(OutputStream out) |
JSONComposer<OutputStream> |
composeTo(Writer w) |
JSONComposer<OutputStream> |
composeUsing(com.fasterxml.jackson.core.JsonGenerator gen) |
com.fasterxml.jackson.core.JsonFactory |
getStreamingFactory() |
com.fasterxml.jackson.core.TreeCodec |
getTreeCodec() |
boolean |
isEnabled(JSON.Feature f) |
List<Object> |
listFrom(Object source) |
<T> List<T> |
listOfFrom(Class<T> type,
Object source) |
<T> Map<T,Object> |
mapFrom(Object source) |
com.fasterxml.jackson.core.Version |
version() |
JSON |
with(CollectionBuilder b)
Mutant factory for constructing an instance with specified
CollectionBuilder ,
and returning new instance (or, if there would be no change, this instance). |
JSON |
with(JSON.Feature... features)
Mutant factory for constructing an instance with specified features
enabled.
|
JSON |
with(JSON.Feature feature,
boolean state)
Mutant factory for constructing an instance with specified feature
enabled or disabled (depending on
state), and returning
an instance with that setting; this may either be this instance (if feature
already had specified state), or a newly constructed instance. |
JSON |
with(com.fasterxml.jackson.core.JsonFactory f) |
JSON |
with(JSONReader r)
Mutant factory for constructing an instance with specified
JSONReader ,
and returning new instance (or, if there would be no change, this instance). |
JSON |
with(JSONWriter w)
Mutant factory for constructing an instance with specified
JSONWriter ,
and returning new instance (or, if there would be no change, this instance). |
JSON |
with(MapBuilder b)
Mutant factory for constructing an instance with specified
MapBuilder ,
and returning new instance (or, if there would be no change, this instance). |
JSON |
with(com.fasterxml.jackson.core.PrettyPrinter pp)
Mutant factory for constructing an instance with specified
PrettyPrinter ,
and returning new instance (or, if there would be no change, this instance). |
JSON |
with(com.fasterxml.jackson.core.TreeCodec c)
Mutant factory for constructing an instance with specified
TreeCodec ,
and returning new instance (or, if there would be no change, this instance). |
JSON |
without(JSON.Feature... features)
Mutant factory for constructing an instance with specified features
disabled.
|
void |
write(Object value,
File f) |
void |
write(Object value,
com.fasterxml.jackson.core.JsonGenerator jgen) |
void |
write(Object value,
OutputStream out) |
void |
write(Object value,
Writer w) |
public static final JSON std
String json = JSON.std.asString(map);
protected final com.fasterxml.jackson.core.JsonFactory _jsonFactory
protected final com.fasterxml.jackson.core.TreeCodec _treeCodec
TreeNode
values: if defined, we can
read and write TreeNode
instances that codec supports.protected final JSONReader _reader
protected final JSONWriter _writer
protected final int _features
protected final com.fasterxml.jackson.core.PrettyPrinter _prettyPrinter
public JSON()
protected JSON(int features, com.fasterxml.jackson.core.JsonFactory jsonF, com.fasterxml.jackson.core.TreeCodec trees)
protected JSON(int features, com.fasterxml.jackson.core.JsonFactory jsonF, com.fasterxml.jackson.core.TreeCodec trees, JSONReader r, JSONWriter w, com.fasterxml.jackson.core.PrettyPrinter pp)
protected JSONReader _defaultReader(int features, com.fasterxml.jackson.core.TreeCodec tc)
protected JSONWriter _defaultWriter(int features, com.fasterxml.jackson.core.TreeCodec tc)
public com.fasterxml.jackson.core.ObjectCodec asCodec()
ObjectCodec
public com.fasterxml.jackson.core.Version version()
version
in interface com.fasterxml.jackson.core.Versioned
public JSON with(com.fasterxml.jackson.core.JsonFactory f)
public JSON with(com.fasterxml.jackson.core.TreeCodec c)
TreeCodec
,
and returning new instance (or, if there would be no change, this instance).public JSON with(JSONReader r)
JSONReader
,
and returning new instance (or, if there would be no change, this instance).public JSON with(JSONWriter w)
JSONWriter
,
and returning new instance (or, if there would be no change, this instance).public JSON with(com.fasterxml.jackson.core.PrettyPrinter pp)
PrettyPrinter
,
and returning new instance (or, if there would be no change, this instance).public JSON with(MapBuilder b)
MapBuilder
,
and returning new instance (or, if there would be no change, this instance).public JSON with(CollectionBuilder b)
CollectionBuilder
,
and returning new instance (or, if there would be no change, this instance).public JSON with(JSON.Feature feature, boolean state)
state), and returning
an instance with that setting; this may either be this instance (if feature
already had specified state), or a newly constructed instance.
public JSON with(JSON.Feature... features)
public JSON without(JSON.Feature... features)
protected final JSON _with(int features)
protected final JSON _with(int features, com.fasterxml.jackson.core.JsonFactory jsonF, com.fasterxml.jackson.core.TreeCodec trees, JSONReader reader, JSONWriter writer, com.fasterxml.jackson.core.PrettyPrinter pp)
public com.fasterxml.jackson.core.TreeCodec getTreeCodec()
public com.fasterxml.jackson.core.JsonFactory getStreamingFactory()
public final boolean isEnabled(JSON.Feature f)
public String asString(Object value) throws IOException, JSONObjectException
IOException
JSONObjectException
public byte[] asBytes(Object value) throws IOException, JSONObjectException
IOException
JSONObjectException
public void write(Object value, com.fasterxml.jackson.core.JsonGenerator jgen) throws IOException, JSONObjectException
IOException
JSONObjectException
public void write(Object value, OutputStream out) throws IOException, JSONObjectException
IOException
JSONObjectException
public void write(Object value, Writer w) throws IOException, JSONObjectException
IOException
JSONObjectException
public void write(Object value, File f) throws IOException, JSONObjectException
IOException
JSONObjectException
public JSONComposer<OutputStream> composeUsing(com.fasterxml.jackson.core.JsonGenerator gen) throws IOException, JSONObjectException
IOException
JSONObjectException
public JSONComposer<OutputStream> composeTo(OutputStream out) throws IOException, JSONObjectException
IOException
JSONObjectException
public JSONComposer<OutputStream> composeTo(Writer w) throws IOException, JSONObjectException
IOException
JSONObjectException
public JSONComposer<OutputStream> composeTo(File f) throws IOException, JSONObjectException
IOException
JSONObjectException
public JSONComposer<String> composeString() throws IOException, JSONObjectException
IOException
JSONObjectException
public JSONComposer<byte[]> composeBytes() throws IOException, JSONObjectException
IOException
JSONObjectException
public CollectionComposer<?,List<Object>> composeList()
public <C extends Collection<Object>> CollectionComposer<?,C> composeCollection(C collection)
public MapComposer<?> composeMap()
public MapComposer<?> composeMap(Map<String,Object> map)
public List<Object> listFrom(Object source) throws IOException, JSONObjectException
IOException
JSONObjectException
public <T> List<T> listOfFrom(Class<T> type, Object source) throws IOException, JSONObjectException
IOException
JSONObjectException
public Object[] arrayFrom(Object source) throws IOException, JSONObjectException
IOException
JSONObjectException
public <T> T[] arrayOfFrom(Class<T> type, Object source) throws IOException, JSONObjectException
IOException
JSONObjectException
public <T> Map<T,Object> mapFrom(Object source) throws IOException, JSONObjectException
IOException
JSONObjectException
public <T> T beanFrom(Class<T> type, Object source) throws IOException, JSONObjectException
IOException
JSONObjectException
public Object anyFrom(Object source) throws IOException, JSONObjectException
Map
for JSON Objects, List
for JSON Arrays, String
for JSON Strings, null for JSON null, Boolean
for JSON booleans
and Number
for JSON numbers.
Supported source types include:
InputStream
Reader
File
URL
String
byte[]
char[]
IOException
JSONObjectException
protected final void _writeAndClose(Object value, com.fasterxml.jackson.core.JsonGenerator jgen) throws IOException, JSONObjectException
IOException
JSONObjectException
protected JSONWriter _writerForOperation(com.fasterxml.jackson.core.JsonGenerator jgen)
protected JSONReader _readerForOperation(com.fasterxml.jackson.core.JsonParser jp)
protected com.fasterxml.jackson.core.JsonParser _parser(Object source) throws IOException, JSONObjectException
IOException
JSONObjectException
protected com.fasterxml.jackson.core.JsonParser _initForReading(com.fasterxml.jackson.core.JsonParser jp) throws IOException, com.fasterxml.jackson.core.JsonProcessingException
IOException
com.fasterxml.jackson.core.JsonProcessingException
protected com.fasterxml.jackson.core.JsonGenerator _config(com.fasterxml.jackson.core.JsonGenerator jgen)
protected com.fasterxml.jackson.core.JsonParser _config(com.fasterxml.jackson.core.JsonParser jp)
protected void _close(Closeable cl)
protected void _close(Closeable cl, Exception e) throws IOException
IOException
Copyright © 2015 FasterXML. All rights reserved.