org.codehaus.jackson.map
Class TreeMapper
java.lang.Object
org.codehaus.jackson.node.JsonNodeFactory
org.codehaus.jackson.map.TreeMapper
public class TreeMapper
- extends JsonNodeFactory
This mapper (or, codec) provides mapping between Json,
and Tree-like structure that consists of child-linked
nodes that can be traversed with simple path operations
(indexing arrays by element, objects by field name).
As of version 0.9.9 of Jackson, most functionality has
been moved away from this class: all serialization and
deserialization features are now accessible through either
ObjectMapper or JsonParser and
JsonGenerator. The remaining functionality is limited
to JsonNodeFactory implementation which allows constructing
typed JsonNode instances.
|
Nested Class Summary |
static class |
TreeMapper.DupFields
Enumeration that defines strategies available for dealing with
duplicate field names (when mapping JSON to Java types). |
| Methods inherited from class org.codehaus.jackson.node.JsonNodeFactory |
arrayNode, binaryNode, binaryNode, booleanNode, nullNode, numberNode, numberNode, numberNode, numberNode, numberNode, numberNode, numberNode, numberNode, objectNode, POJONode, textNode |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_cfgDupFields
protected TreeMapper.DupFields _cfgDupFields
- This option defines how duplicate field names (from JSON input)
are to be handled. Default is to throw a
JsonParseException.
_objectMapper
protected final ObjectMapper _objectMapper
- Mapper that handles actual serialization/deserialization
TreeMapper
public TreeMapper()
TreeMapper
public TreeMapper(ObjectMapper m)
getJsonFactory
public JsonFactory getJsonFactory()
- Method that can be used to get hold of Json factory that this
mapper uses if it needs to construct Json parsers and/or generators.
- Returns:
- Json factory that this mapper uses when it needs to
construct Json parser and generators
readTree
public JsonNode readTree(JsonParser jp)
throws IOException,
JsonParseException
- Method that will try to read a sub-tree using given parser,
map it to a tree (represented by a root JsonNode) and return
it, if possible. Alternatively, if no content is available,
null is returned to signal end-of-content.
- Throws:
IOException
JsonParseException
readTree
public JsonNode readTree(File src)
throws IOException,
JsonParseException
- Throws:
IOException
JsonParseException
readTree
public JsonNode readTree(URL src)
throws IOException,
JsonParseException
- Throws:
IOException
JsonParseException
readTree
public JsonNode readTree(InputStream src)
throws IOException,
JsonParseException
- Throws:
IOException
JsonParseException
readTree
public JsonNode readTree(Reader src)
throws IOException,
JsonParseException
- Throws:
IOException
JsonParseException
readTree
public JsonNode readTree(String jsonContent)
throws IOException,
JsonParseException
- Throws:
IOException
JsonParseException
readTree
public JsonNode readTree(byte[] jsonContent)
throws IOException,
JsonParseException
- Throws:
IOException
JsonParseException
writeTree
public void writeTree(JsonNode rootNode,
File dst)
throws IOException,
JsonParseException
- Throws:
IOException
JsonParseException
writeTree
public void writeTree(JsonNode rootNode,
Writer dst)
throws IOException,
JsonParseException
- Throws:
IOException
JsonParseException
writeTree
public void writeTree(JsonNode rootNode,
OutputStream dst)
throws IOException,
JsonParseException
- Throws:
IOException
JsonParseException