com.smartgwt.client.util
Class JSON

java.lang.Object
  extended by com.smartgwt.client.util.JSON

public class JSON
extends java.lang.Object

Utilities for working with JSON data.


Constructor Summary
JSON()
           
 
Method Summary
static com.google.gwt.core.client.JavaScriptObject decode(java.lang.String jsonString)
          De-serialize an object from JSON.
static java.lang.String encode(com.google.gwt.core.client.JavaScriptObject object)
          Serialize an object as a JSON string.
static java.lang.String encode(com.google.gwt.core.client.JavaScriptObject object, JSONEncoder settings)
          Serialize an object as a JSON string.
 
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

encode

public static java.lang.String encode(com.google.gwt.core.client.JavaScriptObject object)
Serialize an object as a JSON string.

Automatically handles circular references - see circularReferenceMode.

Note that using the String produced by this API with JSON.decode will not successfully preserve dates. Use JSONEncoder.setDateFormat "dateConstructor" to have dates round-trip properly.

Because GWT does not support Java reflection, JSON encoding cannot discover the properties of an arbitrary Java POJO. The following objects are supported:

Parameters:
object - object to serialize
Returns:
object encoded as a JSON String

encode

public static java.lang.String encode(com.google.gwt.core.client.JavaScriptObject object,
                                      JSONEncoder settings)
Serialize an object as a JSON string.

Automatically handles circular references - see circularReferenceMode.

Note that using the String produced by this API with JSON.decode will not successfully preserve dates. Use JSONEncoder.setDateFormat "dateConstructor" to have dates round-trip properly.

Because GWT does not support Java reflection, JSON encoding cannot discover the properties of an arbitrary Java POJO. The following objects are supported:

Parameters:
object - object to serialize
settings - optional settings for encoding
Returns:
object encoded as a JSON String

decode

public static com.google.gwt.core.client.JavaScriptObject decode(java.lang.String jsonString)
De-serialize an object from JSON. Currently, this is simply a JavaScript eval() and should be used for trusted data only.

Parameters:
jsonString - JSON data to be de-serialized
Returns:
object derived from JSON String