java怎么把字符串转成json字符串

如题所述

@RequestMapping(value = "updateInvestorApplyAccountNo", method = RequestMethod.POST)
@ResponseBody
public void updateInvestorApplyAccountNo(HttpServletRequest request,
HttpServletResponse response,
@RequestBody String requestBody) {
int num = 0;
String result = "";

//下面是把拿到的json字符串转成 json对象
JSONObject jsStr = JSONObject.parseObject(requestBody); //将字符串{“id”:1}
//int jsID = Integer.parseInt(jsStr.getString("id"));//获取id的值

/**
* json对象转换成java对象
*/
InvestorApplyModel stud = (InvestorApplyModel) JSONObject.toJavaObject(jsStr,InvestorApplyModel.class);
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-02-13
有几种方式 第一 把字符串存到一个javabean 在 Controller通过@ResponseBody 转换成 JSON
或者 拼接字符串的形式 拼接成 json格式

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网