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 JsonFactory |
_jsonFactory
Underlying JSON factory used for creating Streaming parsers and
generators.
|
protected PrettyPrinter |
_prettyPrinter |
protected JSONReader |
_reader
Blueprint instance of the reader to use for reading JSON as simple
Objects.
|
protected TreeCodec |
_treeCodec
|
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,
JsonFactory jsonF,
TreeCodec trees) |
protected |
JSON(int features,
JsonFactory jsonF,
TreeCodec trees,
JSONReader r,
JSONWriter w,
PrettyPrinter pp) |
Modifier and Type | Method and Description |
---|---|
protected void |
_close(Closeable cl) |
protected void |
_close(Closeable cl,
Exception e) |
protected JsonGenerator |
_config(JsonGenerator g) |
protected JsonParser |
_config(JsonParser p) |
protected JSONReader |
_defaultReader(int features,
TreeCodec tc,
TypeDetector td) |
protected TypeDetector |
_defaultTypeDetector(int features) |
protected JSONWriter |
_defaultWriter(int features,
TreeCodec tc,
TypeDetector td) |
protected JsonParser |
_initForReading(JsonParser p) |
protected void |
_noTreeCodec(String msg) |
protected JsonParser |
_parser(Object source) |
protected JSONReader |
_readerForOperation(JsonParser p) |
protected JSON |
_with(int features)
Internal mutant factory method used for constructing
|
protected JSON |
_with(int features,
JsonFactory jsonF,
TreeCodec trees,
JSONReader reader,
JSONWriter writer,
PrettyPrinter pp) |
protected void |
_writeAndClose(Object value,
JsonGenerator g) |
protected JSONWriter |
_writerForOperation(JsonGenerator gen) |
Object |
anyFrom(Object source)
|
Object[] |
arrayFrom(Object source) |
<T> T[] |
arrayOfFrom(Class<T> type,
Object source) |
byte[] |
asBytes(Object value) |
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(JsonGenerator gen) |
<T extends TreeNode> |
createArrayNode()
Convenience method, equivalent to:
|
<T extends TreeNode> |
createObjectNode()
Convenience method, equivalent to:
|
JsonFactory |
getStreamingFactory() |
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) |
<T extends TreeNode> |
treeFrom(Object source)
Method for reading content as a JSON Tree (of type that configured
TreeCodec , see with(TreeCodec) ) supports. |
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(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(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(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,
JsonGenerator gen) |
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 JsonFactory _jsonFactory
protected final TreeCodec _treeCodec
protected final JSONReader _reader
protected final JSONWriter _writer
protected final int _features
protected final PrettyPrinter _prettyPrinter
public JSON()
protected JSON(int features, JsonFactory jsonF, TreeCodec trees)
protected JSON(int features, JsonFactory jsonF, TreeCodec trees, JSONReader r, JSONWriter w, PrettyPrinter pp)
protected TypeDetector _defaultTypeDetector(int features)
protected JSONReader _defaultReader(int features, TreeCodec tc, TypeDetector td)
protected JSONWriter _defaultWriter(int features, TreeCodec tc, TypeDetector td)
public ObjectCodec asCodec()
ObjectCodec
public JSON with(JsonFactory f)
public JSON with(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(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, JsonFactory jsonF, TreeCodec trees, JSONReader reader, JSONWriter writer, PrettyPrinter pp)
public TreeCodec getTreeCodec()
public 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, JsonGenerator gen) 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(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
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
public <T extends TreeNode> TreeNode treeFrom(Object source) throws IOException, JSONObjectException
TreeCodec
, see with(TreeCodec)
) supports.IOException
JSONObjectException
public <T extends TreeNode> T createArrayNode()
getTreeCodec().createArrayNode();Note that for call to succeed a
TreeCodec
must have been
configured with this instance using with(TreeCodec)
method.public <T extends TreeNode> T createObjectNode()
getTreeCodec().createObjectNode();Note that for call to succeed a
TreeCodec
must have been
configured with this instance using with(TreeCodec)
method.protected final void _writeAndClose(Object value, JsonGenerator g) throws IOException
IOException
protected JSONWriter _writerForOperation(JsonGenerator gen)
protected JSONReader _readerForOperation(JsonParser p)
protected JsonParser _parser(Object source) throws IOException, JSONObjectException
IOException
JSONObjectException
protected JsonParser _initForReading(JsonParser p) throws IOException
IOException
protected JsonGenerator _config(JsonGenerator g)
protected JsonParser _config(JsonParser p)
protected void _close(Closeable cl)
protected void _close(Closeable cl, Exception e) throws IOException
IOException
protected void _noTreeCodec(String msg)
Copyright © 2016 FasterXML. All rights reserved.