Top Description Inners Fields Constructors Methods
tools.jackson.jr.ob

public Class JSON

extends Object
implements ObjectReadContext, ObjectWriteContext, Versioned
Class Inheritance
All Implemented Interfaces
tools.jackson.core.Versioned, tools.jackson.core.ObjectWriteContext, tools.jackson.core.ObjectReadContext
Annotations
@SuppressWarnings:resource
Imports
java.io.*, java.net.URL, java.util.*, tools.jackson.core.*, tools.jackson.core.io.CharacterEscapes, .SegmentedStringWriter, tools.jackson.core.json.JsonFactory, tools.jackson.core.tree.ArrayTreeNode, .ObjectTreeNode, tools.jackson.core.type.ResolvedType, .TypeReference, tools.jackson.core.util.ByteArrayBuilder, .DefaultPrettyPrinter, .Instantiatable, tools.jackson.jr.ob.api.*, tools.jackson.jr.ob.comp.CollectionComposer, .ComposerBase, .MapComposer, tools.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 PrettyPrinter
protected final JSONReader
_reader

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

protected final TokenStreamFactory
_streamFactory

Underlying JSON factory used for creating Streaming parsers and generators.

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, TokenStreamFactory streamF, TreeCodec trees, JSONReader r, JSONWriter w, PrettyPrinter pp)

protected

Method Summary

Modifier and TypeMethod and Description
protected final JsonGenerator
protected final JsonParser
protected JSONReader
protected JSONWriter
protected JsonParser
protected void
protected JsonParser
_parser(Object source)

protected JSONReader
protected final JSON
_with(int features)

Internal mutant factory method used for constructing

protected JSON
_with(int features, TokenStreamFactory 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 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 ArrayTreeNode
createArrayNode()

Implements tools.jackson.core.ObjectReadContext.createArrayNode, tools.jackson.core.ObjectWriteContext.createArrayNode.

Convenience method, equivalent to:

   getTreeCodec().createArrayNode();
public ObjectTreeNode
createObjectNode()

Implements tools.jackson.core.ObjectReadContext.createObjectNode, tools.jackson.core.ObjectWriteContext.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 CharacterEscapes
public int
public int
public PrettyPrinter
getPrettyPrinter()

Implements tools.jackson.core.ObjectWriteContext.getPrettyPrinter.

Accessor for getting PrettyPrinter instance to use for a new generator.

public SerializableString
public FormatSchema
public int
public int
public boolean
hasPrettyPrinter()

Implements tools.jackson.core.ObjectWriteContext.hasPrettyPrinter.

Accessor similar to getPrettyPrinter() but which only indicates whether a non-null instance would be constructed if requested, or not.

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
public <T> T
public <T> T
public <T> T
public StreamReadConstraints
public TokenStreamFactory
public TreeCodec
public <T extends TreeNode> T
treeFrom(Object source)

Method for reading content as a JSON Tree of type that configured 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 supports.

public Version
version()

Implements tools.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
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
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)

public void
public void
writeValue(JsonGenerator g, Object value)

Implements tools.jackson.core.ObjectWriteContext.writeValue.

Method that may be called to serialize given value, using specified token stream generator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait