com.sun.grizzly.cometd.util
Class JSONParser

java.lang.Object
  extended by com.sun.grizzly.cometd.util.JSONParser

public class JSONParser
extends Object


Nested Class Summary
static interface JSONParser.Generator
           
static class JSONParser.Literal
          A Literal JSON generator A utility instance of JSON.Generator that holds a pre-generated string on JSON text.
 
Method Summary
static void append(StringBuilder buffer, Object object)
          Append object as JSON to string buffer.
static byte convertHexDigit(byte b)
           
static Object parse(String s)
           
static String quote(String s)
          Quote a string.
static void quote(StringBuilder buf, String s)
          Quote a string into a StringBuilder.
static String toString(Map object)
           
static String toString(Object object)
           
static String toString(Object[] array)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toString

public static String toString(Object object)

toString

public static String toString(Map object)

toString

public static String toString(Object[] array)

parse

public static Object parse(String s)
Parameters:
s - String containing JSON object or array.
Returns:
A Map, Object array or primitive array parsed from the JSON.

append

public static void append(StringBuilder buffer,
                          Object object)
Append object as JSON to string buffer.

Parameters:
buffer -
object -

quote

public static String quote(String s)
Quote a string. The string is quoted only if quoting is required due to embeded delimiters, quote characters or the empty string.

Parameters:
s - The string to quote.
Returns:
quoted string

quote

public static void quote(StringBuilder buf,
                         String s)
Quote a string into a StringBuilder. The characters ", \, \n, \r, \t, \f and \b are escaped

Parameters:
buf - The StringBuilder
s - The String to quote.

convertHexDigit

public static byte convertHexDigit(byte b)
Parameters:
b - An ASCII encoded character 0-9 a-f A-F
Returns:
The byte value of the character 0-16.


Copyright © 2012 Oracle Corporation. All Rights Reserved.