首页 前端知识 String转Json的几种方式

String转Json的几种方式

2024-05-09 11:05:04 前端知识 前端哥 989 97 我要收藏

第一种:

String格式为:

String result = "{"code":200,"code":"0","message":"SUCCESS"}"
复制

使用:

JSONObject json = JSONObject.parseObject(result);
复制

第二种:

String格式为:

result:
{
"code": 200,
"message": "查询成功",
"result": {
"records": [
{
"jobName": "高级开发工程师",
"jobExperience": "一年以下",
"education": "本科"
},
{
"jobName": "高级开发工程师",
"jobExperience": "一年以下",
"education": "本科"
}
],
"total": 1,
"size": 10,
"current": 1,
"pages": 1
}
}
复制

使用:

JSONObject json = (JSONObject) JSON.toJSON(result);
复制

转载请注明出处或者链接地址:https://www.qianduange.cn//article/7785.html
标签
评论
发布的文章

JQuery中的load()、$

2024-05-10 08:05:15

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!