org.rythmengine.utils
Class JSONWrapper

java.lang.Object
  extended by org.rythmengine.utils.JSONWrapper

public class JSONWrapper
extends Object

Define a type to wrap a JSON string


Constructor Summary
JSONWrapper(String str)
          Construct a JSONWrapper with a JSON string.
 
Method Summary
 List<Object> getArray()
          Return a List of object contained in the JSON array.
 Map<String,Object> getObject()
          Return a Map of String and object contained in the JSON object.
 boolean isArray()
          Return true if the underline JSON data is an array
static JSONWrapper wrap(String s)
          Parse the string and return the JSONWrapper
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONWrapper

public JSONWrapper(String str)
Construct a JSONWrapper with a JSON string. If the string is not valid JSON, then a RuntimeException will thrown out

Parameters:
str -
Method Detail

isArray

public boolean isArray()
Return true if the underline JSON data is an array

Returns:
true if the JSON data is an array

getArray

public List<Object> getArray()
Return a List of object contained in the JSON array.

If the data is not a JSON array then a ClassCastException will be thrown out

Returns:
the List of objects

getObject

public Map<String,Object> getObject()
Return a Map of String and object contained in the JSON object.

If the data is a JSON array then a ClassCastException will be thrown out

Returns:
the mapped json attributes

wrap

public static JSONWrapper wrap(String s)
Parse the string and return the JSONWrapper

Parameters:
s -
Returns:
JSON wrapper of the string


Copyright © 2013. All Rights Reserved.