Java代码中获取Json的key值

测试json字符串:

{"access_token":"hkbQl5o_l67dZ7_vJRATKBwTLk9Yj5QyMuOJThAr8Baj0xWf4wxW1p4ym4iTZ3-ptWRRoVtbCNJnyjGLfed_4bB0HiqGP8v-aXOJUUk1tFs","expires_in":7200,"refresh_token":"_or_31yEp8XhxGWvrAzdWIkXfFlKjfb3iTRpfaN_3kPAVQAPLW6PaW_zmO4GSkC2R0QxqsyJrvLVbDrq4PW9JALi7S6PB8g8yWSwo-PcBqs","openid":"o7jBjwzBUESlQnlLQy_UR25BJe3o","scope":"snsapi_base"}

 

Java代码中获取:

JSONObject jsonObj=JSONObject.parseObject(openId);
String openid=jsonObj.getString("openid");

 

jsp中获取:

先后台设置:mv.addObject("tributes",JSON.toJSON("字符串"));---springMVC、(import com.alibaba.fastjson.*)

前台:JSON.parse('${tributes}');

posted @ 2016-07-13 11:54  权杖攻城狮  阅读(6040)  评论(0编辑  收藏  举报