日期:2014-05-19  浏览次数:20624 次

json串遍历的问题
{"StudentID":61,"CourseID":45,"SubmitSchoolID":0,"SubmitSchoolCode":null,"SubmitTime":"\/Date(1357195709531)\/"}


这样的一个字符串  我想得到  String StudentID = "61" 这种效果  怎么遍历啊

------解决方案--------------------
构建一个对象,然后把json转换为javabean对象,然后获取其中的值。
String str="json的字符串,注意转义符";
ObjectMapper objectMapper = new ObjectMapper();
List<User> listuser=objectMapper.readValue(str, User.class);
------解决方案--------------------
使用json-lib就可以了,json-lib依赖的jar包也要想要的存在
String json="你的json字符串";
JSONObject jsonObject=JSONObject.fromObject(json);
String StudentID=jsonObject.getString("StudentID");1