我正在尝试使用 gson 解析 json。但解析后我的列表总是空的。无法找出错误在哪里。
我的json是这样的
{"d":{"__type":"DealMeDataContract:#SocialEyes.Web.WcfService","DealMe":[{"__type":"DealMe:#SocialEyes.Web.Models","Address":"2075 n power line rd suit 1","CategoryId":"1","CategoryName":"Personal","City":"pompano beach","CreatedDate":"\/Date(1377621018533+0000)\/","DealMeId":"5b9b00d9-e8bf-4197-bd2a-36bc5872359f","Description":"Kick-it is the best phone stand on the market. Works with any phone or any case. Hands free use for watching movies, reading books and more. Get 2 Kick-it Kits now for the price of one. Only $19.99\u000d\u000aYou will not find this Deal Me Anywhere else!","ExpiryDate":"\/Date(1383263940000+0000)\/","HasAgreedTermsAndConditions":true,"ImageUrl":"https:\/\/socialeyesplus.blob.core.windows.net\/prodimages\/image_19bcabce-90cb-4298-9f91-c2c1d0a2161a.jpg","IsNewAddress":false,"LastUpdatedDate":"\/Date(1377621018533+0000)\/","Latitude":26.24161,"Longitude":-80.165909,"PhoneNumber":"(954)-444-8028","PreviousDealAddress":"2075 n power line rd suit 1","PreviousDealCity":"pompano beach","PreviousDealState":"FL","PreviousDealZipCode":"33069","StartDate":"\/Date(1377621017920+0000)\/","State":"FL","StateList":[{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"---Please select a State---","Value":null},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Alabama","Value":"AL"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Alaska","Value":"AK"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Arizona","Value":"AZ"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Arkansas","Value":"AR"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"California","Value":"CA"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Colorado","Value":"CO"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Connecticut","Value":"CT"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Delaware","Value":"DE"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"District of Columbia","Value":"DC"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Florida","Value":"FL"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Georgia","Value":"GA"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Guam","Value":"GU"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Hawaii","Value":"HI"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Idaho","Value":"ID"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Illinois","Value":"IL"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Indiana","Value":"IN"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Iowa","Value":"IA"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Kansas","Value":"KS"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Kentucky","Value":"KY"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Louisiana","Value":"LA"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Maine","Value":"ME"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Maryland","Value":"MD"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Massachusetts","Value":"MA"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Michigan","Value":"MI"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Minnesota","Value":"MN"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Mississippi","Value":"MS"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Missouri","Value":"MO"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Montana","Value":"MT"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Nebraska","Value":"NE"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Nevada","Value":"NV"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"New Hampshire","Value":"NH"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"New Jersey","Value":"NJ"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"New Mexico","Value":"NM"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"New York","Value":"NY"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"North Carolina","Value":"NC"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"North Dakota","Value":"ND"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Ohio","Value":"OH"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Oklahoma","Value":"OK"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Oregon","Value":"OR"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Pennsylvania","Value":"PA"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Puerto Rico","Value":"PR"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Rhode Island","Value":"RI"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"South Carolina","Value":"SC"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"South Dakota","Value":"SD"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Tennessee","Value":"TN"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Texas","Value":"TX"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Utah","Value":"UT"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Vermont","Value":"VT"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Virginia","Value":"VA"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Washington","Value":"WA"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"West Virginia","Value":"WV"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Wisonsin","Value":"WI"},{"__type":"SelectListItem:#System.Web.Mvc","Selected":false,"Text":"Wyoming","Value":"WY"}],"SubCategoryId":"124","SubCategoryName":"Electronics","Title":"Kickit phone stand ","UserId":"6851e89f-4a32-496e-b2b6-ea461f31b3bd","ZipCode":"33069"}],"Status":"Success"}}
要将 json 转换为 java 对象,我创建了一个这样的类
public class AllDeals {
public String _type;
public List<Deal> DealMe = new ArrayList<AllDeals.Deal>();
public String Status;
public List<Deal> getDealList() {
return DealMe;
}
public static class Deal {
public String __type;
public String Address;
public String CategoryId;
public String CategoryName;
public String City;
public String CreatedDate;
public String DealMeId;
public String Description;
public String ExpiryDate;
public String HasAgreedTermsAndConditions;
public String ImageUrl;
public String IsNewAddress;
public String LastUpdatedDate;
public String Latitude;
public String Longitude;
public String PhoneNumber;
public String PreviousDealAddress;
public String PreviousDealCity;
public String PreviousDealState;
public String PreviousDealZipCode;
public String StartDate;
public String State;
public List<AllDeals.StateList> StateList;
public String SubCategoryId;
public String SubCategoryName;
public String Title;
public String UserId;
public String ZipCode;
}
public static class StateList {
public String __type;
public String Selected;
public String Text;
public String Value;
}
}
private final Gson mGson = new Gson();
AllDeals cateResponse = mGson.fromJson(jsonString, AllDeals.class);
我的列表总是空的无法找出原因