我會保持簡短,我有一個問題,一些非常糟糕的佈局Json(從我可以告訴無論如何),我從Web服務撤回,新來的Java /安卓/ JSON,因此我們將感激地收到任何幫助,將JSON的結構是:解析奇怪的構造Json/Gson
> {"cursor": > {"currentPageIndex":0, > "estimatedResultCount":32, > "pages":{ > "label":1, > "start":0}, > "responseDetails":null, > "responseStatus":200}, "results":[ > {"accuracy":24140, > "addressLines": > {"Address1":"A house number", > "Address2":"A Street", > "Address3":"A city", > "Address4":"A State", > "Address5":"A Country", > "Postcode":"123456"}, > "city":"A City", > "country":"A Country", > "ddUrl":"http://link1.com", > "ddUrlFromHere":"http://link2.com", > "ddUrlToHere":"http://link3.com", > "lat":54.52909583, > "lng":-0.45554611, > "phoneNumbers": > {"number":"123456789", > "type":"work"}, > "region":"China", > "staticMapUrl":"http://link4.com", > "streetAddress":"A house number, A Street, A city, A State, > 123456", > "title":"Ali Baba Carpets", > "titleNoFormatting":"<strong>Ali Baba > Carpets</strong>", > "url":"http://link5.com"}]}
我試圖使用解析它:
import java.util.List;
public class ParseOffers {
private List<results> results;
public static class cursor {
private int currentPageIndex;
private int estimatedResultCount;
private pages Pages;
private String ResponseDetails;
private int ResponseStatus;
public class pages {
private int label;
private int start;
}
}
public static class results {
private int Accuracy;
private addressLines AddressLines;
private String city;
private String country;
private String ddUrl;
private String ddUrlFromHere;
private String ddUrlToHere;
private double lat;
private double lng;
private phoneNumbers data;
private String region;
private String staticMapUrl;
private String streetAddress;
private String title;
private String titleNoFormatting;
private String url;
public class addressLines {
private String Address1;
private String Address2;
private String Address3;
private String Address4;
private String Address5;
private String Postcode;
}
public class phoneNumbers {
private String number;
private String type;
}
}
}
謝謝。
你如何解析它?手工或使用標準庫? org.json'包中的adroid sdk應該能夠解析這種東西:[javadoc] –
@Aleks G(http://developer.android.com/reference/org/json/package-summary.html) - OP說Gson正在使用。顯然是在數據綁定模式下。 –