org.codehaus.jackson.map
Class TreeMapper

java.lang.Object
  extended by org.codehaus.jackson.node.JsonNodeFactory
      extended by 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).
 
Field Summary
protected  TreeMapper.DupFields _cfgDupFields
          This option defines how duplicate field names (from JSON input) are to be handled.
protected  ObjectMapper _objectMapper
          Mapper that handles actual serialization/deserialization
 
Fields inherited from class org.codehaus.jackson.node.JsonNodeFactory
instance
 
Constructor Summary
TreeMapper()
           
TreeMapper(ObjectMapper m)
           
 
Method Summary
 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.
 JsonNode readTree(byte[] jsonContent)
           
 JsonNode readTree(java.io.File src)
           
 JsonNode readTree(java.io.InputStream src)
           
 JsonNode readTree(JsonParser jp)
          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.
 JsonNode readTree(java.io.Reader src)
           
 JsonNode readTree(java.lang.String jsonContent)
           
 JsonNode readTree(java.net.URL src)
           
 void writeTree(JsonNode rootNode, java.io.File dst)
           
 void writeTree(JsonNode rootNode, java.io.OutputStream dst)
           
 void writeTree(JsonNode rootNode, java.io.Writer dst)
           
 
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
 

Field Detail

_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

Constructor Detail

TreeMapper

public TreeMapper()

TreeMapper

public TreeMapper(ObjectMapper m)
Method Detail

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 java.io.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:
java.io.IOException
JsonParseException

readTree

public JsonNode readTree(java.io.File src)
                  throws java.io.IOException,
                         JsonParseException
Throws:
java.io.IOException
JsonParseException

readTree

public JsonNode readTree(java.net.URL src)
                  throws java.io.IOException,
                         JsonParseException
Throws:
java.io.IOException
JsonParseException

readTree

public JsonNode readTree(java.io.InputStream src)
                  throws java.io.IOException,
                         JsonParseException
Throws:
java.io.IOException
JsonParseException

readTree

public JsonNode readTree(java.io.Reader src)
                  throws java.io.IOException,
                         JsonParseException
Throws:
java.io.IOException
JsonParseException

readTree

public JsonNode readTree(java.lang.String jsonContent)
                  throws java.io.IOException,
                         JsonParseException
Throws:
java.io.IOException
JsonParseException

readTree

public JsonNode readTree(byte[] jsonContent)
                  throws java.io.IOException,
                         JsonParseException
Throws:
java.io.IOException
JsonParseException

writeTree

public void writeTree(JsonNode rootNode,
                      java.io.File dst)
               throws java.io.IOException,
                      JsonParseException
Throws:
java.io.IOException
JsonParseException

writeTree

public void writeTree(JsonNode rootNode,
                      java.io.Writer dst)
               throws java.io.IOException,
                      JsonParseException
Throws:
java.io.IOException
JsonParseException

writeTree

public void writeTree(JsonNode rootNode,
                      java.io.OutputStream dst)
               throws java.io.IOException,
                      JsonParseException
Throws:
java.io.IOException
JsonParseException