我正在使用Gson Library在我的android程序中解析我的JSON请求。我的Json就像这样
{
"max_rental_rate": "9.00",
"average_rental_rate": "6.00",
"electricity_rate": "0.31",
"water_rate": "2.00",
"direct_line_exchange": "0.04",
"buildings": [
{
"value": "3",
"revision_id": "3"
},
{
"value": "4",
"revision_id": "4"
}
],
"map-image": "<img typeof=\"foaf:Image\"src=\"http://ccims.badrulmi.com/sites/default/files/styles/medium/public/3quarter_view_low.jpg?itok=Ac1mv9U5\" width=\"220\" height=\"165\" />"
}
每一个人都在解析,直到我到达地图图像。这可能是什么问题? 下面是我的java代码。
我的解析代码:
GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson = gsonBuilder.create();
MainContainer mainContainer = gson.fromJson(result, MainContainer.class);
和我的主要容器类
{
private String max_rental_rate;
private String average_rental_rate;
private String electricity_rate;
private String water_rate;
private String direct_line_exchange;
private String direct_line_remarks;
private String internet;
private String internet_remarks;
private ArrayList<Buildings> buildings;
private String mapimage;
}
感谢任何帮助。
谢谢,
答案 0 :(得分:2)
使用注释:
@SerializedName("map-image")
private String mapimage;
使用注释,它会告诉gson解析器有关命名空间的更改