edu.internet2.middleware.grouperClientExt.util
Class JsonUtils

java.lang.Object
  extended by edu.internet2.middleware.grouperClientExt.util.JsonUtils

public class JsonUtils
extends Object

Author:
mchyzer

Constructor Summary
JsonUtils()
           
 
Method Summary
static Object jsonConvertFrom(Map<String,Class<?>> conversionMap, String json)
          convert an object from json.
static Object jsonConvertFrom(String json, Class<?> theClass)
          convert an object from json.
static String jsonConvertTo(Object object)
          convert an object to json.
static void jsonConvertTo(Object object, Writer writer)
          convert an object to json.
static String jsonConvertToNoWrap(Object object)
          convert an object to json without wrapping it with the simple class name.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonUtils

public JsonUtils()
Method Detail

jsonConvertFrom

public static Object jsonConvertFrom(Map<String,Class<?>> conversionMap,
                                     String json)
convert an object from json. note this works well if there are no collections, just real types, arrays, etc.

Parameters:
conversionMap - is the class simple name to class of objects which are allowed to be brought back. Note: only the top level object needs to be registered
json -
Returns:
the object

jsonConvertFrom

public static Object jsonConvertFrom(String json,
                                     Class<?> theClass)
convert an object from json. note this works well if there are no collections, just real types, arrays, etc.

Parameters:
json - is the json string, not wrapped with a simple class name
theClass - is the class that the object should be coverted into. Note: only the top level object needs to be registered
Returns:
the object

jsonConvertTo

public static String jsonConvertTo(Object object)
convert an object to json.

Parameters:
object -
Returns:
the string of json

jsonConvertTo

public static void jsonConvertTo(Object object,
                                 Writer writer)
convert an object to json. note this wraps the gson with the object simple name so it can be revived

Parameters:
object -
writer -

jsonConvertToNoWrap

public static String jsonConvertToNoWrap(Object object)
convert an object to json without wrapping it with the simple class name.

Parameters:
object -
Returns:
the string of json

main

public static void main(String[] args)
Parameters:
args -


Copyright © 2012 Internet2. All Rights Reserved.