com.bowstreet.util
Class JSONUtil

java.lang.Object
  extended by com.bowstreet.util.JSONUtil

public class JSONUtil
extends java.lang.Object

Utility class for working with JSON data.


Constructor Summary
JSONUtil()
           
 
Method Summary
static boolean isValid(java.io.Reader reader)
          Checks if the data from the specified Reader is valid JSON.
static boolean isValid(java.lang.String json)
          Checks if the specified string is valid JSON.
static IXml json2Xml(java.io.Reader reader)
          Converts the JSON from the specified Reader to an XML representation.
static IXml json2Xml(java.io.Reader reader, JSON2XMLHandler handler)
          Converts the JSON from the specified Reader to an XML representation.
static IXml json2Xml(java.lang.String json)
          Converts the JSON string to an XML representation.
static IXml json2Xml(java.lang.String json, JSON2XMLHandler handler)
          Converts the JSON string to an XML representation.
static java.lang.String xml2JSON(java.io.InputStream xml, boolean verbose)
          Converts the specified xml to a JSON representation.
static void xml2JSON(java.io.InputStream xml, java.io.OutputStream jsonOutput, boolean verbose)
          Converts the specified xml to a JSON representation.
static java.lang.String xml2JSON(IXml xml, boolean verbose)
          Converts the specified xml to a JSON representation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONUtil

public JSONUtil()
Method Detail

isValid

public static boolean isValid(java.io.Reader reader)
Checks if the data from the specified Reader is valid JSON. This performs the check by parsing the JSON.

Parameters:
reader - The Reader to fetch the JSON from.
Returns:
true if valid JSON, else false.

isValid

public static boolean isValid(java.lang.String json)
Checks if the specified string is valid JSON. This performs the check by parsing the JSON.

Parameters:
json - The JSON String
Returns:
true if valid JSON, else false.

json2Xml

public static IXml json2Xml(java.io.Reader reader)
Converts the JSON from the specified Reader to an XML representation.

Parameters:
reader - The Reader to fetch the JSON from.
Returns:
The XML results of the converted JSON.

json2Xml

public static IXml json2Xml(java.io.Reader reader,
                            JSON2XMLHandler handler)
Converts the JSON from the specified Reader to an XML representation.

Parameters:
reader - The Reader to fetch the JSON from.
handler - A JSON2XMLHandler converter handler.
Returns:
The XML results of the converted JSON.

json2Xml

public static IXml json2Xml(java.lang.String json)
Converts the JSON string to an XML representation.

Parameters:
json - The JSON String
Returns:
The XML results of the converted JSON.

json2Xml

public static IXml json2Xml(java.lang.String json,
                            JSON2XMLHandler handler)
Converts the JSON string to an XML representation.

Parameters:
json - The JSON String
handler - A JSON2XMLHandler converter handler.
Returns:
The XML results of the converted JSON.

xml2JSON

public static java.lang.String xml2JSON(java.io.InputStream xml,
                                        boolean verbose)
Converts the specified xml to a JSON representation.

Parameters:
xml - An InputStream to read the XML from
verbose - specifies whether verbose formatting including spacing and newlines should be used
Returns:
The JSON results.

xml2JSON

public static void xml2JSON(java.io.InputStream xml,
                            java.io.OutputStream jsonOutput,
                            boolean verbose)
Converts the specified xml to a JSON representation.

Parameters:
xml - An InputStream to read the XML from
jsonOutput - An OutputStream to write the converted JSON object to.
verbose - specifies whether verbose formatting including spacing and newlines should be used

xml2JSON

public static java.lang.String xml2JSON(IXml xml,
                                        boolean verbose)
Converts the specified xml to a JSON representation.

Parameters:
xml - The IXml representation of the XML
verbose - specifies whether verbose formatting including spacing and newlines should be used
Returns:
The JSON results.


Copyright © 2009 IBM. All Rights Reserved.