Java 字符串转换实体类_JAVA之JSON字符串转换实体类

@Override

public String getExamPaper(String examID, String userID) throws Exception{

String strResult;

ExamQuestion entity;

strResult = examObjectStudentRep.getExamPaper(examID, userID);

entity = JSON.parseObject(JSON.parse(strResult).toString(),ExamQuestion.class);

return examObjectStudentRep.getExamPaper(examID, userID);

}

/

JSON格式的String字符串

{

"service":{

"count":"20",

"item":[

{

"id":"EES_SS1830738",

"type":"1",

"question":"题目1",

"value":"5",

"rightanswer":"3",

"option":[

{

"id":"1",

"description":"答案"

},

{

"id":"2",

"description":"答案2"

},

{

"id":"3",

"description":"答案2"

},

{

"id":"4",

"description":"建议书"

}

]

},

{

"id":"EES_MS0654246",

"type":"2",

"question":"题目",

"value":"5",

"rightanswer":"1,3,4",

"option":[

{

"id":"1",

"description":"12321321"

},

{

"id":"2",

"description":"12321321 "

},

{

"id":"3",

"description":"12321312"

},

{

"id":"4",

"description":"12321"

}

]

},

{

"id":"EES_JU0561902",

"type":"3",

"question":"12312312",

"value":"5",

"rightanswer":"0",

"option":[

{

"id":"1",

"description":"是"

},

{

"id":"0",

"description":"否"

}

]

}

]

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值