xv.json
Class JSON

java.lang.Object
  extended by xv.json.JSON

public class JSON
extends Object

Main utility class for dealing with JSON.

Author:
xv

Constructor Summary
JSON()
           
 
Method Summary
static JSONVariant parse(InputStream in)
          Parse the given input as JSON.
static JSONVariant parse(Reader reader)
          Parse the given input as JSON.
static JSONVariant parse(String string)
          Parses the given string as a JSON document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSON

public JSON()
Method Detail

parse

public static JSONVariant parse(InputStream in)
                         throws IOException,
                                JSONException
Parse the given input as JSON. This assumes the encoding is UTF-8. This does not close the stream when it completes.

Parameters:
in - the stream to read from
Returns:
the parsed JSON value
Throws:
IOException - if an I/O exception occurs
JSONException - if an error occurs parsing the JSON content

parse

public static JSONVariant parse(String string)
                         throws JSONException
Parses the given string as a JSON document. At present, this stops after parsing the first JSON object/array.

Parameters:
string - the string to parse
Returns:
the parsed JSON value
Throws:
JSONException - if an error occurs parsing the JSON content

parse

public static JSONVariant parse(Reader reader)
                         throws IOException,
                                JSONException
Parse the given input as JSON. The reader is not closed when it completes.

Parameters:
in - the reader to read from
Returns:
the parsed JSON value
Throws:
IOException - if an I/O exception occurs
JSONException - if an error occurs parsing the JSON content


Copyright © 2008-2011. All Rights Reserved.