goods类里面有一个属性goods_desc是String类型的
把它取出来再用gson解一次
创建类
package com.baway.test.gengdi20160602.bean;
public class MyGoods {
private String id;
private String goods_name;
private String goods_desc;
private String market_price;
private String shop_price;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getGoods_name() {
return goods_name;
}
public void setGoods_name(String goods_name) {
this.goods_name = goods_name;
}
public String getGoods_desc() {
return goods_desc;
}
public void setGoods_desc(String goods_desc) {
this.goods_desc = goods_desc;
}
public String getMarket_price() {
return market_price;
}
public void setMarket_price(String market_price) {
this.market_price = market_price;
}
public String getShop_price() {
return shop_price;
}
public void setShop_price(String shop_price) {
this.shop_price = shop_price;
}
@Override
public String toString() {
return "MyGoods [id=" + id + ", goods_Name=" + goods_name
+ ", goods_desc=" + goods_desc + ", market_price="
+ market_price + ", shop_price=" + shop_price + "]";
}
}
package com.baway.test.gengdi20160602.bean;
public class MyGoodsDesc {
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public String toString() {
return "MyGoodsDesc [url=" + url + "]";
}
}
得到goods_desc后
private void initData() {
HttpUtils httpUtils=new HttpUtils();
httpUtils.send(HttpMethod.GET, urlStr+id, new RequestCallBack() {
@Override
public void onFailure(HttpException arg0, String arg1) {
Toast.makeText(TwoActivity.this, "请求失败", Toast.LENGTH_LONG).show();
}
@Override
public void onSuccess(ResponseInfo<String> arg0) {
String result = arg0.result;
// Log.d(“gengdi”, result.toString());
//开始解析数据
Gson gson=new Gson();
MyBean02 fromJson = gson.fromJson(result.toString(), MyBean02.class);
data = fromJson.getData();
goods = data.getGoods();
String goods_desc = goods.getGoods_desc();
Gson gson2=new Gson();
goods_de = gson2.fromJson(goods_desc.toString(), new TypeToken