如何将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个回答

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

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

发到你哪里啊

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐