Alex Rivera | Logout

GWT (Client) = How to convert Object to JSON and send to Server?

Asked 2011-04-14T05:27:50.113
9

I know that GWT has a good RPC support. But for various purposes I need to build this on my own:

1.) How can I convert a Bean Object (on the Client Side) like;

class MyPerson {

String name;
String getName();
void setName(String name);
//..    
}

with GWT into a JSON String? (Ideally only using libraries that come officially from GWT/Google).

2.) Secondly, how can I send this generated JSON String from the Client side to any Server also using any GWT Client Logik. (Ideally only using libraries that come officially from GWT/Google).

I have searched a lot, but the examples never show how to send data but only to receive JSON data.

Thank you very much!!! Jens

Edit
Report

1 Answer

0

Take a look at GWT's AutoBean framework, which can be used to create and receive JSON payloads. The RequestBuilder type can be used to send HTTP requests to the server.

answered 2011-04-14T12:09:52.773

Your Answer