Sorry, under com.google.gwt.json.client
On Tue, Nov 9, 2010 at 11:49 PM, Gal Dolber <gal.dol...@gmail.com> wrote:

> So you need to use:
>
> http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/index.html?overview-summary.html
>
>
> On Tue, Nov 9, 2010 at 10:48 PM, Kashif <kashifshaikh...@gmail.com> wrote:
>
>> No, I don't want to use Overlays - because that forces me to have a
>> DTO class that has separate implementation on client and server.
>>
>> The whole point of using JSONObject is that I have a java API that I
>> can use to marshall/unmarshall DTO objects regardless if I'm sending
>> them from client to server or vice versa.
>>
>>
>>
>> On Nov 9, 9:29 pm, Gal Dolber <gal.dol...@gmail.com> wrote:
>> > The best you can use in the client to handle json are Overlays.
>> http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsOver...
>> >
>> >
>> >
>> >
>> >
>> > On Tue, Nov 9, 2010 at 7:17 PM, Kashif <kashifshaikh...@gmail.com>
>> wrote:
>> > > Hi everyone,
>> >
>> > > I have a class that I want to share both with client and server code,
>> > > in my particular case it's the JSONObject.
>> >
>> > > It has different implementations on client
>> > > (com.google.gwt.json.client.JSONObject) and server
>> > > (org.json.JSONObject), but same interface.
>> >
>> > > So I have a DTO class like this shared between client and server, so I
>> > > can use JSON to pass objects around and wrap them in JSONObjects for
>> > > easy API access:
>> >
>> > > class Person {
>> >
>> > >    String firstName;
>> > >    String lastName;
>> >
>> > >    public JSONObject toJson()
>> > >    {
>> > >       // code to convert firstname + lastname to JSON
>> > >    }
>> >
>> > >    public fromJSON (JSONObject x)
>> > >    {
>> > >       // code to read from JSONObject and set firstName and lastName
>> > >    }
>> > > }
>> >
>> > > There is no way for me to tell GWT to use
>> > > com.google.gwt.json.client.JSONObject when compiling this class on
>> > > client, and likewise use org.json.JSONObject on server. I would have
>> > > to resort to Java String.
>> >
>> > > Now I could do the following, but I would have to re-write the toJson/
>> > > fromJson methods for each implementation -  not acceptable to me!
>> >
>> > > class PersonBase
>> > > {
>> > >  String firstname;
>> > >  String lastname;
>> > > }
>> >
>> > > class Person_Client extends PersonBase
>> > > {
>> > >    public fromJSON (om.google.gwt.json.client.JSONObject x)
>> > >    {
>> > >       // code to read from JSONObject and set firstName and lastName
>> > >    }
>> >
>> > >    public com.google.gwt.json.client.JSONObject toJson()
>> > >    {
>> > >       // code to convert firstname + lastname to JSON
>> > >    }
>> > > }
>> >
>> > > class Person_Server extends PersonBase
>> > > {
>> > >    public fromJSON (org.json.JSONObject x)
>> > >    {
>> > >       // code to read from JSONObject and set firstName and lastName
>> > >    }
>> >
>> > >    public org.json.JSONObject toJson()
>> > >    {
>> > >       // code to convert firstname + lastname to JSON
>> > >    }
>> > > }
>> >
>> > > There must be an easier way!
>> >
>> > > --
>> > > You received this message because you are subscribed to the Google
>> Groups
>> > > "Google Web Toolkit" group.
>> > > To post to this group, send email to
>> google-web-tool...@googlegroups.com.
>> > > To unsubscribe from this group, send email to
>> > > google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com><google-web-toolkit%2Bunsubs
>> cr...@googlegroups.com>
>> > > .
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/google-web-toolkit?hl=en.
>> >
>> > --
>> > Guit: Elegant, beautiful, modular and *production ready* gwt
>> applications.
>> >
>> > http://code.google.com/p/guit/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Web Toolkit" group.
>> To post to this group, send email to google-web-tool...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>>
>
>
> --
> Guit: Elegant, beautiful, modular and *production ready* gwt applications.
>
> http://code.google.com/p/guit/
>
>
>
>
>


-- 
Guit: Elegant, beautiful, modular and *production ready* gwt applications.

http://code.google.com/p/guit/

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to