PDA

View Full Version : JSON Example?



Tereno
7 Jul 2008, 2:45 PM
Hi there,

I am wondering if someone could point me to examples of utilizing web services that return JSON strings back as well as XML and the normal SOAP.

Currently for JSON, I'm using the GWT like this:


private class JSONResponseTextHandler implements RequestCallback {
public void onError(Request request, Throwable exception) {
//error
}

public void onResponseReceived(Request request, Response response) {
String responseText = response.getText();
try {
JSONValue jsonValue = JSONParser.parse(responseText);
label2.setText(jsonValue.toString());
} catch (JSONException e) {
label2.setText(responseText);
}

}
}


Is there any other way to do it using GXT?

Thanks

darrellmeyer
9 Jul 2008, 7:01 PM
Take a look at XmlTablePage in the explorer demo. The source code is in the download.

Tereno
10 Jul 2008, 9:17 AM
When we receive a JSON Object, do we still have to parse it or can we automatically use the Object itself?

darrellmeyer
10 Jul 2008, 9:23 PM
You can use a JsonReader which will parse the text and create model instances. Take a look at this post http://extjs.com/forum/showthread.php?t=39874.