org.directwebremoting.json
Class JsonUtil

java.lang.Object
  extended by org.directwebremoting.json.JsonUtil

public class JsonUtil
extends java.lang.Object

Various utilities to make parsing and reading JSON easier

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Constructor Summary
JsonUtil()
           
 
Method Summary
static java.lang.String getErrors(java.io.Reader reader)
          Get a record of any errors in parsing the input document
static java.lang.String getErrors(java.lang.String input)
          Get a record of any errors in parsing the input string
static java.lang.String toJson(java.lang.Object data)
          Convert arbitrary convertible data into a JSON string.
static void toJson(java.lang.Object data, java.io.Writer out)
          Convert arbitrary convertible data into a JSON string and write it out to the given Writer
static
<T> T
toReflectedTypes(java.lang.Class<T> marshallInto, java.io.Reader reader)
          Convert the input document into a set of basic types
static
<T> T
toReflectedTypes(java.lang.Class<T> marshallInto, java.lang.String input)
          Convert the input string into a set of basic types
static java.util.List<java.lang.Object> toSimpleArray(java.io.Reader reader)
          Convert the input document into a set of basic types
static java.util.List<java.lang.Object> toSimpleArray(java.lang.String input)
          Convert the input string into a set of basic types
static java.util.Map<java.lang.String,java.lang.Object> toSimpleObject(java.io.Reader reader)
          Convert the input document into a set of basic types
static java.util.Map<java.lang.String,java.lang.Object> toSimpleObject(java.lang.String input)
          Convert the input string into a set of basic types
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonUtil

public JsonUtil()
Method Detail

getErrors

public static java.lang.String getErrors(java.lang.String input)
Get a record of any errors in parsing the input string


getErrors

public static java.lang.String getErrors(java.io.Reader reader)
Get a record of any errors in parsing the input document


toSimpleObject

public static java.util.Map<java.lang.String,java.lang.Object> toSimpleObject(java.lang.String input)
                                                                       throws JsonParseException
Convert the input string into a set of basic types

Throws:
JsonParseException

toSimpleObject

public static java.util.Map<java.lang.String,java.lang.Object> toSimpleObject(java.io.Reader reader)
                                                                       throws JsonParseException
Convert the input document into a set of basic types

Throws:
JsonParseException

toSimpleArray

public static java.util.List<java.lang.Object> toSimpleArray(java.lang.String input)
                                                      throws JsonParseException
Convert the input string into a set of basic types

Throws:
JsonParseException

toSimpleArray

public static java.util.List<java.lang.Object> toSimpleArray(java.io.Reader reader)
                                                      throws JsonParseException
Convert the input document into a set of basic types

Throws:
JsonParseException

toReflectedTypes

public static <T> T toReflectedTypes(java.lang.Class<T> marshallInto,
                                     java.lang.String input)
                          throws JsonParseException
Convert the input string into a set of basic types

Throws:
JsonParseException

toReflectedTypes

public static <T> T toReflectedTypes(java.lang.Class<T> marshallInto,
                                     java.io.Reader reader)
                          throws JsonParseException
Convert the input document into a set of basic types

Throws:
JsonParseException

toJson

public static void toJson(java.lang.Object data,
                          java.io.Writer out)
                   throws java.io.IOException
Convert arbitrary convertible data into a JSON string and write it out to the given Writer

Throws:
java.io.IOException

toJson

public static java.lang.String toJson(java.lang.Object data)
                               throws java.io.IOException
Convert arbitrary convertible data into a JSON string.

Throws:
java.io.IOException

Copyright 2008