Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion : Re: Creating JSON Object

Received: by 10.143.132.9 with SMTP id j9mr5942171wfn.23.1302674572544;
        Tue, 12 Apr 2011 23:02:52 -0700 (PDT)
X-BeenThere: google-gson@googlegroups.com
Received: by 10.143.87.9 with SMTP id p9ls509428wfl.3.p; Tue, 12 Apr 2011
 23:02:50 -0700 (PDT)
Received: by 10.142.149.35 with SMTP id w35mr612855wfd.1.1302674570490;
        Tue, 12 Apr 2011 23:02:50 -0700 (PDT)
Received: by 10.142.149.35 with SMTP id w35mr612854wfd.1.1302674570451;
        Tue, 12 Apr 2011 23:02:50 -0700 (PDT)
Return-Path: <inder...@gmail.com>
Received: from mail-px0-f180.google.com (mail-px0-f180.google.com [209.85.212.180])
        by gmr-mx.google.com with ESMTPS id 28si294695wfb.2.2011.04.12.23.02.50
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 12 Apr 2011 23:02:50 -0700 (PDT)
Received-SPF: pass (google.com: domain of inder...@gmail.com designates 209.85.212.180 as permitted sender) client-ip=209.85.212.180;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of inder...@gmail.com designates 209.85.212.180 as permitted sender) smtp.mail=inder...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by mail-px0-f180.google.com with SMTP id 25so283386pxj.25
        for <google-gson@googlegroups.com>; Tue, 12 Apr 2011 23:02:50 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:cc:content-type:content-transfer-encoding;
        bh=SgKtbrKtS/jncAcjxHYNAHkCQqH0tFygrwXqeSjx0GQ=;
        b=SGXSHMthC3GyFMSNR2tUit6Pju3AwuYslWd/EOebgTyCo1Wle4DeKVCT5oc5e/BQ61
         lgf0swDfbVL1jKdtpxPxKNHc5fZkX2WAjRsr9mKnROan0eg81eW7pu9ba+8IFFww4BsG
         2eXaIODw+HleKSN9hmfX6VvFNsx7/kiPGQz2U=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :cc:content-type:content-transfer-encoding;
        b=TtMFem2w3rPn+SB7Bq5fVCcLEI5EAkYdtlG5yAXSCYdknj/Ikk71BHSe+Z9V4U6f+d
         ovabWXyiYVxQdJYo2K9YvuriXSR++xlk3XAxiFBB4CXcjQCcUvS/4eyWC/6P9NxR4gNk
         +dmUJkeU6wSIy0w3/CypMvYu1dV+rqrpVmR9o=
Received: by 10.142.107.12 with SMTP id f12mr3713699wfc.226.1302674570240;
 Tue, 12 Apr 2011 23:02:50 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.68.57.71 with HTTP; Tue, 12 Apr 2011 23:02:30 -0700 (PDT)
In-Reply-To: <1f4e43bc-e0d6-4c33-8b8e-e01fa0184...@k3g2000prl.googlegroups.com>
References: <c38b9b31-f0dc-4751-844f-f03716c13...@d28g2000yqc.googlegroups.com>
 <d101ff23-65f1-499d-9438-025fdc23f...@d26g2000prn.googlegroups.com>
 <25e145ba-18fb-4bff-82e3-050e5293d...@z27g2000prz.googlegroups.com>
 <727d5d29-9856-4ad0-b125-dee098882...@n2g2000prj.googlegroups.com> <1f4e43bc-e0d6-4c33-8b8e-e01fa0184...@k3g2000prl.googlegroups.com>
From: Inderjeet Singh <inder...@gmail.com>
Date: Tue, 12 Apr 2011 23:02:30 -0700
Message-ID: <BANLkTimyyPEYL18AHxZpvq_FQqLnMZL...@mail.gmail.com>
Subject: Re: [google-gson:1020]: Re: Creating JSON Object
To: google-gson@googlegroups.com
Cc: Kyle <frigh...@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Good to know that it worked for you. In general Gson can not
deserialize into Object type except if it is a primitive.
We did improve handling of certain edge cases around that (when it is
List or Map of Objects) so that is probably what made it work for you.

Inder


On Tue, Apr 12, 2011 at 5:52 PM, Kyle <frigh...@gmail.com> wrote:
> Okay, so apparently 1.7 fixed the problem... thanks :D I was really
> close to being done though! I worked on that error for days and to
> have it fixed after someone actually tried to help me :P (I asked soo
> many ppl in so many places :P)
>
> On Apr 12, 4:50=A0pm, "inder...@gmail.com" <inder...@gmail.com> wrote:
>> Gson would not be able to deserialize into List<Object> since it
>> doesn't know how to create a concrete class for "Object".
>>
>> Inder
>>
>> On Apr 12, 2:23=A0pm, Kyle <frigh...@gmail.com> wrote:
>>
>>
>>
>>
>>
>>
>>
>> > Would you say JsonBlock class is that top level class? I have not put
>> > in the options yet. Also, does Gson support deserializing
>> > List<Object>???
>>
>> > On Apr 12, 1:20=A0pm, "inder...@gmail.com" <inder...@gmail.com> wrote:
>>
>> > > I guess you need a top-level class too:
>> > > Class TopLevel {
>> > > Series series;
>> > > Options options;
>>
>> > > }
>>
>> > > Other than that I dont see a problem with your code. What is the
>> > > specific error you are running into? Would help if you can share a
>> > > JUnit test that we can reproduce.
>>
>> > > Inder
>>
>> > > On Apr 12, 12:55=A0am, Kyle <frigh...@gmail.com> wrote:
>>
>> > > > Hey everyone, so I have been dealing with an issue deserializing m=
y
>> > > > object. I get the feeling that I am not creating the object correc=
tly,
>> > > > so here is what I have.
>>
>> > > > The structure I am attempting to put the data into follows this st=
yle.
>>
>> > > > {
>> > > > =A0 "series": [{
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "data":[[long,long], ... ],
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "label":String
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 },{
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "data":[[long,long], ... ],
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "label":String
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 },
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ...
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ],
>> > > > =A0 "options:{
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "mouse":{"track":true},
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "xaxis":{"noTicks":10},
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "points":{"show":true},
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "lines":{"show":true}
>> > > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 }
>>
>> > > > }
>>
>> > > > My attempt at doing this looks something like this:
>>
>> > > > class JsonBlock {
>> > > > =A0 =A0 List<Series> series =3D new ArrayList<Series>();
>>
>> > > > }
>>
>> > > > class Series {
>> > > > =A0 =A0 List<long[]> data =3D new ArrayList<long[]>();
>> > > > =A0 =A0 String label =3D "";
>> > > > =A0 =A0 public Series(String label, long[] d) { this.label =3D lab=
el;
>> > > > data.add(d); }
>>
>> > > > }
>
> --
> You received this message because you are subscribed to the Google Groups=
 "google-gson" group.
> To post to this group, send email to google-gson@googlegroups.com.
> To unsubscribe from this group, send email to google-gson+unsubscribe@goo=
glegroups.com.
> For more options, visit this group at http://groups.google.com/group/goog=
le-gson?hl=3Den.
>
>