【发布时间】:2018-08-24 03:12:21
【问题描述】:
我从查询中得到 Alphabet 并列出 Country,我怎样才能制作这样的 JSON? 我不知道这个。我怎样才能创建一些这样的 JSON?
> List=[
> {Alphabet:'B',
> Country:[
> {name: 'Belgia'}
> ]},
> {Alphabet:'I',
> Country:[
> {name: 'Indonesia'}
> ]},
> {Alphabet:'N',
> Country:[
> {name: 'Namibia'}
> ]},
> {Alphabet:'O',
> Country:[
> {name: 'Ohio'}
> ]},
> {Alphabet:'T',
> Country:[
> {name: 'Turki'},
> {name: 'Tunisia'}
> ]},
> {Alphabet:'Y',
> Country:[
> {name: 'Yaman'},
> ]} ];
我有一些这样的模型
> public class ListCountry {
> private String Alphabet;
> List<ListCountryObj> List;
>
> public void setAlphabet(String Alphabet){this.Alphabet= Alphabet;}
> public void setList(List<ListCountryObj> List){this.List = List;}
>
> public String getAlphabet(){return this.Alphabet;}
> public List<ListCountryObj> getList() {return List;} }
还有这个
> public class ListCountryObj {
> private String country;
>
> public void setCountry(String country){this.country = country;}
> public String getCountry(){return this.country;} }
【问题讨论】: