com.ibm.commons.util.io.json
Class JsonParser

java.lang.Object
  extended by com.ibm.commons.util.io.json.JsonParser

public class JsonParser
extends java.lang.Object

JSON parser.

This class provides some methods for generating parsing JSON text and create objects out of it. It uses a factory to deal with the actual object classes.


Constructor Summary
JsonParser()
           
 
Method Summary
static java.lang.Object fromJson(JsonFactory factory, java.io.Reader reader)
          Parse a JSON stream and return an object.
static java.lang.Object fromJson(JsonFactory factory, java.lang.String json)
          Parse a JSON text and return an object.
static boolean isJson(java.lang.String json)
          Check if a string a a valid JSON text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonParser

public JsonParser()
Method Detail

isJson

public static boolean isJson(java.lang.String json)
Check if a string a a valid JSON text.

Parameters:
json - the JSON text to check
Returns:
true if the string is a JSON object
Throws:
JsonException

fromJson

public static java.lang.Object fromJson(JsonFactory factory,
                                        java.lang.String json)
                                 throws JsonException
Parse a JSON text and return an object.

Parameters:
factory - the object factory
json - the JSON text
Returns:
the object created from the JSON text
Throws:
JsonException

fromJson

public static java.lang.Object fromJson(JsonFactory factory,
                                        java.io.Reader reader)
                                 throws JsonException
Parse a JSON stream and return an object.

Parameters:
factory - the object factory
reader - the JSON stream
Returns:
the object created from the JSON text
Throws:
JsonException