Article View: pl.comp.lang.java
Article #153453Re: GSON określony format pomocy
From: J-23
Date: Mon, 28 May 2012 14:13
Date: Mon, 28 May 2012 14:13
80 lines
2721 bytes
2721 bytes
W dniu 28.05.2012 07:20, Arivald pisze:
> W dniu 2012-05-28 00:53, J-23 pisze:
>> Witam
>> Mam problem próbuje za pomocą GSON uzyskać takiego JSON: (Poradzcie coś
>> bo mi jakoś z JSON nie idzie)
>>
>> {
>> records:[{
>> name:'Middleton, Wendy V.',
>> email:'morbi.tristique@iaculisquis.org',
>> phone:5574291911,
>> state:'TX',
>> zip:'51334'
>> },
> [...]
>> {
>> name:'Dennis, Desiree Q.',
>> email:'eu.eros.Nam@Nullam.com',
>> phone:4715368003,
>> state:'AK',
>> zip:'N3J 9X4'
>> }]
>> }
>
> Po pierwsze, ten JSON jest błędny. Detale sprawdź np. tu:
> http://jsonformatter.curiousconcept.com/ , lub dowolnym innym walidatorem.
nie wiem możliwe ja tego jsona wziałem stad:
http://www.sencha.com/examples-2/data/data.json
Potrzebuje zbudować takiego jsona żebym mógł go wczytać w gridy (robilem
to jakis czas temu ale skleroza mnie dopadła)
Chodzi o te Grid
http://www.sencha.com/examples-2/#jsongrid
>
> powinno to wyglądać raczej tak:
>
>
> {
> "records":[{
> "name":"Middleton, Wendy V.",
> "email":"morbi.tristique@iaculisquis.org",
> "phone":"5574291911",
> "state":"TX",
> "zip":"51334"
> },
> [...]
> {
> "name":"Dennis, Desiree Q.",
> "email":"eu.eros.Nam@Nullam.com",
> "phone":"4715368003",
> "state":"AK",
> "zip":"N3J 9X4"
> }]
> }
>
>
> A od strony Javy to nic prostszego (w/g dokumentacji, bo sam używam
> czego innego)...
>
> public class Person {
> public String name;
> public String email;
> public String phone;
> public String state;
> public String zip;
> }
>
> public class People {
> public Person[] records;
> }
>
> ... i serializujesz "People".
>
Dzięki ci za przypomnienie
Pozdrawiam
Technical Details
Message-ID:
<jq01ac$56l$1@mx1.internetia.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!news.cyf-kr.edu.pl!news.nask.pl!news.nask.org.pl!news.internetia.pl!not-for-mailReferences:
<jpubee$57r$1@mx1.internetia.pl> <jpv1rn$20r$1@news.dialog.net.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!news.cyf-kr.edu.pl!news.nask.pl!news.nask.org.pl!news.internetia.pl!not-for-mail From: J-23 <baczeklu@poczta.fm> Newsgroups: pl.comp.lang.java Subject: Re: GSON określony format pomocy Date: Mon, 28 May 2012 16:13:20 +0200 Organization: Netia S.A. Lines: 80 Message-ID: <jq01ac$56l$1@mx1.internetia.pl> References: <jpubee$57r$1@mx1.internetia.pl> <jpv1rn$20r$1@news.dialog.net.pl> NNTP-Posting-Host: 77-253-91-204.adsl.inetia.pl Mime-Version: 1.0 X-Trace: mx1.internetia.pl 1338214540 5333 77.253.91.204 (28 May 2012 14:15:40 GMT) X-Complaints-To: abuse@inetia.pl NNTP-Posting-Date: Mon, 28 May 2012 14:15:40 +0000 (UTC) In-Reply-To: <jpv1rn$20r$1@news.dialog.net.pl> X-Tech-Contact: usenet@internetia.pl User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 X-Server-Info: http://www.internetia.pl/ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit