org.mule.module.json
Class JsonData

java.lang.Object
  extended by org.mule.module.json.JsonData
All Implemented Interfaces:
java.io.Serializable

public class JsonData
extends java.lang.Object
implements java.io.Serializable

A wrapper for the JsonNode object that allows for nested object keys i.e. user/name will return the name property on the user object.

There is no 'xpath' for JSON yet (though I expect Jackson to do implement this at some point). This class provides a simple way to navigate a Json data structure. To select a child entry use - person/name

to access array data, use square braces with an index value i.e. person/addresses[0]/postcode

or

[0]/arrayElement

Also, multi-dimensional arrays can be accessed using: filters[1]/init[1][0]

if a Json property name contains a '/' the name needs to be quoted with single quotes i.e.

results/'http://foo.com'/value

See Also:
Serialized Form

Constructor Summary
JsonData(java.io.InputStream node)
           
JsonData(org.codehaus.jackson.JsonNode node)
           
JsonData(java.io.Reader node)
           
JsonData(java.lang.String node)
           
JsonData(java.net.URL node)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 org.codehaus.jackson.JsonNode get(int index)
           
 java.lang.Object get(java.lang.String expression)
           
 int hashCode()
           
 boolean hasNode(java.lang.String key)
           
 boolean isArray()
           
protected  java.util.List<java.lang.String> parseTokens(java.lang.String expresion)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonData

public JsonData(org.codehaus.jackson.JsonNode node)

JsonData

public JsonData(java.net.URL node)
         throws java.io.IOException
Throws:
java.io.IOException

JsonData

public JsonData(java.io.InputStream node)
         throws java.io.IOException
Throws:
java.io.IOException

JsonData

public JsonData(java.io.Reader node)
         throws java.io.IOException
Throws:
java.io.IOException

JsonData

public JsonData(java.lang.String node)
         throws java.io.IOException
Throws:
java.io.IOException
Method Detail

get

public org.codehaus.jackson.JsonNode get(int index)

isArray

public boolean isArray()

get

public java.lang.Object get(java.lang.String expression)

hasNode

public boolean hasNode(java.lang.String key)

parseTokens

protected java.util.List<java.lang.String> parseTokens(java.lang.String expresion)

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.