datangdongjing
jingjdong1023
2011-08-24 12:35

如何将json字符串包含多个list集合嵌套加到实体对象中?

已采纳

类一:

public class DriverPointResult{

public List<Text> basicInfo;
public List<IllegalItem> illegalInfo;
public List<IllegalItem> illegalNoPaymentBeforeClearPoint;

....get set 方法
}

类二:

public class Text{
:wink:
private String content;

private List<Text> subInfo;

private String title;

....get set 方法
}
类三:

public class IllegalItem {

public Double amount;
public String dealTime;
public String illegalAction;
public String illegalAddress;
public int number;
public Boolean payed;
public String point;

....get set 方法
}
如下相当于json字符串:

String resptransport = "[{'basicInfo':[{'content':'content1','subInfo':[{'content':'content11','subInfo':'','title':'title11'},{'content':'content12','subInfo':'','title':'title12'}],'title':'title1'}],'illegalInfo':[{'amount':'amount','dealTime':'dealTime','illegalAction':'illegalAction','illegalAddress':'illegalAddress','number':'number','payed':'payed','point':'point'}],'illegalNoPaymentBeforeClearPoint':[{'amount':'amount','dealTime':'dealTime','illegalAction':'illegalAction','illegalAddress':'illegalAddress','number':'number','payed':'payed','point':'point'}]}]";

请求高人相助!!!需要要得到一个DriverPointResult实体类

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • renpeng301 renpeng301 10年前

    [code="java"]
    json-lib.jar
    JSONObject json1 = JSONObject.fromString(resptransport);
    Object bean1 = JSONObject.toBean(json1);
    然后强制转换成 ··DriverPointResult
    [/code]

    点赞 评论 复制链接分享
  • AngelAndAngel AngelAndAngel 10年前

    发到你哪里啊

    点赞 评论 复制链接分享
  • AngelAndAngel AngelAndAngel 10年前

    我这里有个json转化为java对象的包 不知道你要不要。

    点赞 评论 复制链接分享

相关推荐