Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.jr.ob

public Class JSON

extends Object
implements Versioned
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.core.Versioned
Annotations
@SuppressWarnings:resource
Imports
java.io.*, java.net.URL, java.util.*, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.io.SegmentedStringWriter, com.fasterxml.jackson.core.util.ByteArrayBuilder, .Instantiatable, com.fasterxml.jackson.jr.ob.api.*, com.fasterxml.jackson.jr.ob.comp.CollectionComposer, .ComposerBase, .MapComposer, com.fasterxml.jackson.jr.ob.impl.*

Main entry point for functionality for reading and writing JSON and configuring details of reading and writing.

Note that instances are fully immutable, and thereby thread-safe.

Note on source types: source to read is declared as java.lang.Object but covers following types:

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
JSON.Builder

Builder class that needs to be used for certain kind of "static" configuration (settings that can not vary on per-call basis for JSON), such as Extension registration.

private static class
JSON.ExtContextImpl

Extension context implementation used when

public static enum
JSON.Feature

Simple on/off (enabled/disabled) features for JSON; used for simple configuration aspects.

Field Summary

Modifier and TypeField and Description
protected final int
protected final JsonFactory
_jsonFactory

Underlying JSON factory used for creating Streaming parsers and generators.

protected final PrettyPrinter
protected final JSONReader
_reader

Blueprint instance of the reader to use for reading JSON as simple Objects.

protected final TreeCodec
_treeCodec

Optional handler for TreeNode values: if defined, we can read and write TreeNode instances that codec supports.

protected final ValueReaderLocator
protected final ValueWriterLocator
protected final JSONWriter
_writer

Blueprint instance of the writer to use for writing JSON given simple Objects.

public static final int
pack-priv static final int
public static final JSON
std

Singleton instance with standard, default configuration.

Constructor Summary

AccessConstructor and Description
public
JSON()

public
public
JSON(JSON.Builder
Builder that has configured settings to use.
b
)

Constructor used when creating instance using Builder.

protected
JSON(JSON base, int features, JsonFactory jsonF, TreeCodec trees, JSONReader r, JSONWriter w, PrettyPrinter pp)

protected

Method Summary

Modifier and TypeMethod and Description
protected void
protected <T> T
protected JsonGenerator
protected JsonParser
protected JSONReader
protected JSONWriter
protected JsonParser
protected void
protected JsonParser
_parser(Object source)

protected JSONReader
protected <T> T
protected final 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 final void
protected JSONWriter
public Object
anyFrom(Object source)

Read method that will take given JSON Source (of one of supported types), read contents and map it to one of simple mappings (java.util.Map for JSON Objects, java.util.List for JSON Arrays, java.lang.String for JSON Strings, null for JSON null, java.lang.Boolean for JSON booleans and java.lang.Number for JSON numbers.

public ValueIterator<Object>
anySequenceFrom(Object source)

Method for creating ValueIterator for reading streaming JSON content (specifically line-delimited and concatenated variants); individual values are bound as "Simple" type: java.util.Map, java.util.List, String, Number or Boolean.

public Object[]
arrayFrom(Object source)

public <T> T[]
arrayOfFrom(Class<T> type, Object source)

public byte[]
asBytes(Object value)

public ObjectCodec

Returns:

Wrapper over this object to adapt to ObjectCodec API
asCodec
()

Convenience method for constructing an adapter that uses this instance as a ObjectCodec

public String
public <T> T
beanFrom(Class<T> type, Object source)

public <T> ValueIterator<T>
beanSequenceFrom(Class<T> type, Object source)

Method for creating ValueIterator for reading streaming JSON content (specifically line-delimited and concatenated variants); individual values are bound to specific Bean (POJO) type.

public static JSON.Builder
public static JSON.Builder
builder(JsonFactory streamFactory)

public JSONComposer<byte[]>
public <C extends Collection<Object>> CollectionComposer<?, C>
composeCollection(C collection)

public CollectionComposer<?, List<Object>>
public MapComposer<?>
public MapComposer<?>
public JSONComposer<String>
public JSONComposer<OutputStream>
public JSONComposer<OutputStream>
public JSONComposer<OutputStream>
public JSONComposer<OutputStream>
public <T extends TreeNode> T
createArrayNode()

Convenience method, equivalent to:

   getTreeCodec().createArrayNode();
public <T extends TreeNode> T
createObjectNode()

Convenience method, equivalent to:

   getTreeCodec().createObjectNode();
public JsonParser
createParser(Object source)

Factory method for opening a JsonParser to read content from one of following supported sources

public JsonFactory
public TreeCodec
public final boolean
public List<Object>
listFrom(Object source)

public <T> List<T>
listOfFrom(Class<T> type, Object source)

public Map<String, Object>
mapFrom(Object source)

public <T> Map<String, T>
mapOfFrom(Class<T> type, Object source)

Read method for reading a Map of type (usually POJO) values.

public <T extends TreeNode> T
treeFrom(Object source)

Method for reading content as a JSON Tree (of type that configured TreeCodec, see with(TreeCodec)) supports.

public <T extends TreeNode> ValueIterator<T>
treeSequenceFrom(Object source)

Method for creating ValueIterator for reading streaming JSON content (specifically line-delimited and concatenated variants); individual values are bound as JSON Trees(of type that configured TreeCodec, see with(TreeCodec)) supports.

public Version
version()

Implements com.fasterxml.jackson.core.Versioned.version.

Method called to detect version of the component that implements this interface; returned version should never be null, but may return specific "not available" instance (see Version for details).

public JSON

Returns:

New instance with specified PrettyPrinter (if not same as currently configured); this otherwise.
with
(PrettyPrinter
PrettyPrinter to use for pretty-printing output (of null to disable pretty-printing)
pp
)

Mutant factory for constructing an instance with specified PrettyPrinter, and returning new instance (or, if there would be no change, this instance).

public 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.

public JSON
with(JSON.Feature... features)

Mutant factory for constructing an instance with specified features enabled.

public JSON

Returns:

New instance with specified factory (if not same as currently configured); this otherwise.
with
(JsonFactory
Jackson core format factory to use for low-level decoding/encoding
f
)
Deprecated Since 2.11 should not try changing underlying stream factory but create a new instance if necessary: method will be removed from 3.0 at latest

Mutant factory method for constructing new instance with specified JsonFactory if different from currently configured one (if not, return this as-is)

public JSON

Returns:

New instance with specified codec (if not same as currently configured); this otherwise.
with
(TreeCodec
Tree codec to use for reading/writing of tree representation
c
)
Deprecated Since 2.11 should try using builder (see builder() and create properly configured instance

Mutant factory for constructing an instance with specified TreeCodec, and returning new instance (or, if there would be no change, this instance).

public JSON

Returns:

New instance with specified JSONReader (if not same as currently configured); this otherwise.
with
(JSONReader
Customized JSONReader to use instead of standard one
r
)
Deprecated Since 2.11 should try using builder (see builder() and create properly configured instance

Mutant factory for constructing an instance with specified JSONReader, and returning new instance (or, if there would be no change, this instance).

public JSON

Returns:

New instance with specified JSONWriter (if not same as currently configured); this otherwise.
with
(JSONWriter
Customized JSONWriter to use instead of standard one
w
)
Deprecated Since 2.11 should try using builder (see builder() and create properly configured instance

Mutant factory for constructing an instance with specified JSONWriter, and returning new instance (or, if there would be no change, this instance).

public 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).

public 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).

public JSON
with(ReaderWriterProvider rwp)
Deprecated Since 2.11 should register using JacksonJrExtension

Mutant factory for constructing an instance with specified ReaderWriterProvider, and returning new instance (or, if there would be no change, this instance).

public JSON
without(JSON.Feature... features)

Mutant factory for constructing an instance with specified features disabled.

public void
public void
public void
write(Object value, Writer w)

public void
write(Object value, File f)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait