我正在尝试创建一个对象,使用杰克逊图书馆将JSON响应绑定到我的对象,但我不知道如何定义一些文件,例如类别,邻域,位置和地址。
来自JSON的示例回复
{"region":
{"span":
{"latitude_delta": 0.10262262794520893, "longitude_delta": 0.22282942},
"center": {"latitude": 51.510372893357001, "longitude": -0.1108336}},
"total": 246, "businesses": [{"is_claimed": false,
"rating": 4.5,
"mobile_url": "http://m.yelp.co.uk/biz/r-garcia-and-sons-foods-and-wines-of-spain-london",
"rating_img_url": "http://s3-media2.ak.yelpcdn.com/assets/2/www/img/99493c12711e/ico/stars/v1/stars_4_half.png",
"review_count": 11,
"name": "R Garcia \u0026 Sons - Foods and Wines of Spain",
"snippet_image_url": "http://s3-media2.ak.yelpcdn.com/photo/8xquccU5FKaFg9ZlANdOJA/ms.jpg",
"rating_img_url_small": "http://s3-media2.ak.yelpcdn.com/assets/2/www/img/a5221e66bc70/ico/stars/v1/stars_small_4_half.png",
"url": "http://www.yelp.co.uk/biz/r-garcia-and-sons-foods-and-wines-of-spain-london",
"phone": "+442072216119",
"snippet_text": "aka R Garcia \u0026 Son, and Cafe Garcia. Although, technically, Cafe Garcia is next door attached to their la carniceria. \n\nIt is a great Spanish grocery store...",
"image_url": "http://s3-media3.ak.yelpcdn.com/bphoto/t14haXQrAW8HMwc0RTL1jQ/ms.jpg",
"categories": [["Delis", "delis"], ["Spanish", "spanish"], ["Beer, Wine \u0026 Spirits", "beer_and_wine"]],
"display_phone": "+44 20 7221 6119",
"rating_img_url_large": "http://s3-media4.ak.yelpcdn.com/assets/2/www/img/9f83790ff7f6/ico/stars/v1/stars_large_4_half.png",
"id": "r-garcia-and-sons-foods-and-wines-of-spain-london",
] "is_closed": false,
"location": {"city": "London", "display_address": ["248-250 Portobello Road", "Notting Hill", "London W11 1LL", "UK"],
"neighborhoods": ["Notting Hill"],
"postal_code": "W11 1LL",
"country_code": "GB",
"address": ["248-250 Portobello Road"],
"state_code": "XGL"}},
{"is_claimed": false, "rating": 3.0, ......
课程
public class Region {
private Span span;
getter and setter
}
public class Span {
private double latitude_delta;
private double longitude_delta;
private Center center;
private int total;
private Businesses businesses;
getter and setter
}
public class Center {
private double latitude;
private double longtitude;
getter and setter
}
public class Businesses {
private boolean is_claimed;
private double rating;
private String mobile_url;
private String rating_img_url;
private int review_count;
private String name;
private String snipper_image_url;
private String rating_img_url_small;
private String url;
private String phone;
private String snippet_text;
private String image_url;
private categories; <<<<<<<<<<<<<<<<<
private String display_phone;
private String rating_img_url_large;
private String id;
private boolean is_closed;
private Location location; <<<<<<<<
private neighborhoods <<<<<<<<<
private String postal_code;
private String country_code;
private address <<<<<<<<<<
private String state_code;
getters and setters
}
答案 0 :(得分:2)
categories
:明星列表清单。您可以使用数组而不是列表。
class Location {
String city;
String[] displayAddress; // you can use list instead
}
neighborhoods
- 我在你的json中看不到这样的字段。
String[] address;
//或按以前的情况列出。