码迷,mamicode.com
首页 > 编程语言 > 详细

JAVA之JSON字符串转换实体类

时间:2018-12-06 20:32:26      阅读:288      评论:0      收藏:0      [点我收藏+]

标签:val   count   objects   ice   trre   use   turn   paper   override   

@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":"否"
}
]
}
]
}
}

JAVA之JSON字符串转换实体类

标签:val   count   objects   ice   trre   use   turn   paper   override   

原文地址:https://www.cnblogs.com/jtcr/p/10078202.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!