ps : 没啥难点! 总结的两个要点错误请纠正 不想看的直接复制代码运行看结果就行
- 简单例子为例 (例子在下面 习惯总结写上面 没有好的排版经验)
- 简单例子没啥要点了 照着套就行 … 之前用的 javascript 比较简单直接 data.lieks 就是结果
// 先解析
JSONObject object = JSONObject.parseObject(str);
// 想取code的值 直接用object跟想要的属性的值 object.get("code")
System.out.println("code = " + object.get("code"));
// 如果{} 里面还有一个 {}嵌套 就取上层的元素定位 (不知道是不是叫元素知道了叫啥再改) , 这里我想要likes 的值 就是 getJSONObject("data") 然后和上面一样 get("likes") 想要的属性的值就行
Object likes = object.getJSONObject("data").get("likes");
System.out.println("likes = " + likes);
这是简单例子
{
"code": 0,
"success": true,
"data": {
"result": 0,
"likes": 1,
"inlikes": true,
"n_dolikes": 0,
"show_10_likes_gift": false,
"toast": ""
}
}
这是简单例子的java代码
public static void main(String[] args) {
// 这是一个小红书点赞的返回值
String str = "{\"code\":0,\"success\":true,\"data\":{\"result\":0,\"likes\":1,\"inlikes\":true,\"n_dolikes\":0,\"show_10_likes_gift\":false,\"toast\":\"\"}}";
// 先把String对象转换成json对象
JSONObject object = JSONObject.parseObject(str);
// 取data的JSONObject 因为data里面还是一个json对象所以可以直接get拿到likes的数
Object likes = object.getJSONObject("data").get("likes");
// 返回 1 失败 不是 1 则是成功
System.out.println("likes = " + likes);
}
- 复杂例子为例 (也没啥好例子这个比较长…顺手用到做个总结)
- 这个我上来也容易混淆的就是getJSONArray 和 getJSONObject 什么时候用 , 根据[] 和{} 来决定 []就用getJSONArray(“上一层的值”) 然后getJSONObject(第几个下标) {}就直接getJSONObject(“上一层的值”)
- 用法fastjson官网看的找了个最简单的例子复制过来直接套进去了…有兴趣的自己看下其他用法。
- 总结 : 大概就这样吧…也不是啥高手,高手也不会拿着个做笔记,最近在做爬虫和逆向以后还要经常解析json,主要还是怕自己忘了。
// 通过 想要取 喜欢 533 和 收藏 203 的值
// data[0]['note_list'][0]['liked_count'] 这是用定位工具直接找到要入库的值
// data[0]['note_list'][0]['collected_count'] 这是用定位工具直接找到要入库的值
// 先解析
JSONObject object = JSONObject.parseObject(str);
// data 里面是个[] 就是getJSONArray("data") 又是下标0 就是getJSONObject(0)
JSONObject data = object.getJSONArray("data").getJSONObject(0);
// 下面是['note_list'][0] 照着上面再套一次 一模一样就不详述了
JSONObject note_list = data.getJSONArray("note_list").getJSONObject(0);
// 最后拿到 liked_count 和 collected_count 和简单例子讲的一样直接get("liked_count")
Object liked_count = note_list.get("liked_count");
Object collected_count = note_list.get("collected_count");
System.out.println("liked_count = " + liked_count + " collected_count = " + collected_count);
这是复杂例子
{
"code": 0,
"success": true,
"data": [
{
"track_id": "",
"user": {
"id": "5b8e8d5dd2bbb00001e824eb",
"name": "怡倩YIQIAN",
"image": "https://sns-avatar-qc.xhscdn.com/avatar/5e8eb850e61bf20001dc3b15.jpg?imageView2/2/w/120/format/jpg",
"followed": false,
"red_id": "yiqianbra",
"nickname": "怡倩YIQIAN",
"red_official_verify_type": 0,
"show_red_official_verify_icon": false,
"red_official_verified": false,
"level": {
"image": ""
}
},
"note_list": [
{
"id": "601bc6f10000000001001aa6",
"type": "normal",
"title": "3招拯救胸部松软没弹性📗打造挺拔胸型❗️",
"desc": "⏰帮女生解决胸部烦恼的倩倩我又来啦~\n依旧是广大女生们提出来的困扰:\n为什么胸部会松软干瘪,[可怜R]像装了水的气球一样往下垂,胸线下移,非常不美观呢?\n[叹气R]总是在“怎么调整胸型”、“怎么选内衣”之间碰壁,找不到真正的改善方法!\n[皱眉R]这次科普倩倩准备了你们最关心的3个问题!\n1、先来自测一下,自己胸部是否处于松软状态?\n2、胸部松软,不挺拔是什么原因引起的?\n3、胸部松软该怎么改善?\n都整理在图片上了,记得自测一下自己胸部会不会松软!分享给身边有需要的小姐妹哦!\n下期你们想解惑哪些困扰呢[吧唧R]",
"hash_tag": [],
"ats": [],
"images_list": [
{
"fileid": "73d9294a-1640-3e06-a356-79f0f90404f9",
"height": 1333,
"width": 1000,
"url": "http://sns-img-qc.xhscdn.com/73d9294a-1640-3e06-a356-79f0f90404f9?imageView2/2/w/1080/format/webp",
"original": "http://sns-img-qc.xhscdn.com/73d9294a-1640-3e06-a356-79f0f90404f9",
"trace_id": "73d9294a-1640-3e06-a356-79f0f90404f9"
},
{
"fileid": "50919ed3-72b2-3761-9f21-5ea8d5804f1c",
"height": 1333,
"width": 1000,
"url": "http://sns-img-qc.xhscdn.com/50919ed3-72b2-3761-9f21-5ea8d5804f1c?imageView2/2/w/1080/format/webp",
"original": "http://sns-img-qc.xhscdn.com/50919ed3-72b2-3761-9f21-5ea8d5804f1c",
"trace_id": "50919ed3-72b2-3761-9f21-5ea8d5804f1c"
},
{
"fileid": "feb84357-e2ad-306a-b6db-bc8d94ff8d69",
"height": 1333,
"width": 1000,
"url": "http://sns-img-qc.xhscdn.com/feb84357-e2ad-306a-b6db-bc8d94ff8d69?imageView2/2/w/1080/format/webp",
"original": "http://sns-img-qc.xhscdn.com/feb84357-e2ad-306a-b6db-bc8d94ff8d69",
"trace_id": "feb84357-e2ad-306a-b6db-bc8d94ff8d69"
},
{
"fileid": "8fd0aaea-c243-3f2c-9429-87c5b8772271",
"height": 1333,
"width": 1000,
"url": "http://sns-img-qc.xhscdn.com/8fd0aaea-c243-3f2c-9429-87c5b8772271?imageView2/2/w/1080/format/webp",
"original": "http://sns-img-qc.xhscdn.com/8fd0aaea-c243-3f2c-9429-87c5b8772271",
"trace_id": "8fd0aaea-c243-3f2c-9429-87c5b8772271"
},
{
"fileid": "ad37c8f1-25f9-3d78-96cb-f499fefea669",
"height": 1333,
"width": 1000,
"url": "http://sns-img-qc.xhscdn.com/ad37c8f1-25f9-3d78-96cb-f499fefea669?imageView2/2/w/1080/format/webp",
"original": "http://sns-img-qc.xhscdn.com/ad37c8f1-25f9-3d78-96cb-f499fefea669",
"trace_id": "ad37c8f1-25f9-3d78-96cb-f499fefea669"
},
{
"fileid": "ebca23be-dd7f-34ca-af09-62cb92f42343",
"height": 1333,
"width": 1000,
"url": "http://sns-img-qc.xhscdn.com/ebca23be-dd7f-34ca-af09-62cb92f42343?imageView2/2/w/1080/format/webp",
"original": "http://sns-img-qc.xhscdn.com/ebca23be-dd7f-34ca-af09-62cb92f42343",
"trace_id": "ebca23be-dd7f-34ca-af09-62cb92f42343"
},
{
"fileid": "a80a055e-0f86-30b6-bc69-882026403856",
"height": 1333,
"width": 1000,
"url": "http://sns-img-qc.xhscdn.com/a80a055e-0f86-30b6-bc69-882026403856?imageView2/2/w/1080/format/webp",
"original": "http://sns-img-qc.xhscdn.com/a80a055e-0f86-30b6-bc69-882026403856",
"trace_id": "a80a055e-0f86-30b6-bc69-882026403856"
},
{
"fileid": "c9a86867-8191-37dc-8d48-956a1057ff74",
"height": 1333,
"width": 1000,
"url": "http://sns-img-qc.xhscdn.com/c9a86867-8191-37dc-8d48-956a1057ff74?imageView2/2/w/1080/format/webp",
"original": "http://sns-img-qc.xhscdn.com/c9a86867-8191-37dc-8d48-956a1057ff74",
"trace_id": "c9a86867-8191-37dc-8d48-956a1057ff74"
},
{
"fileid": "ade72f4d-721f-3484-97bb-0e67497d9428",
"height": 1705,
"width": 1279,
"url": "http://sns-img-qc.xhscdn.com/ade72f4d-721f-3484-97bb-0e67497d9428?imageView2/2/w/1080/format/webp",
"original": "http://sns-img-qc.xhscdn.com/ade72f4d-721f-3484-97bb-0e67497d9428",
"trace_id": "ade72f4d-721f-3484-97bb-0e67497d9428"
}
],
"user": {
"id": "5b8e8d5dd2bbb00001e824eb",
"name": "怡倩YIQIAN",
"image": "https://sns-avatar-qc.xhscdn.com/avatar/5e8eb850e61bf20001dc3b15.jpg?imageView2/2/w/120/format/jpg",
"followed": false,
"red_id": "yiqianbra",
"nickname": "怡倩YIQIAN",
"red_official_verify_type": 0,
"show_red_official_verify_icon": false,
"red_official_verified": false,
"level": {
"image": ""
}
},
"time": 1612433137,
"last_update_time": 1612497894,
"poi": {},
"liked": false,
"liked_count": 533,
"collected": false,
"collected_count": 203,
"comments_count": 21,
"sticky": false,
"share_info": {
"content": "⏰帮女生解决胸部烦恼的倩倩我又来啦~ 依旧是广大女生们提出来的困扰: 为什么胸部会松软干瘪,[可怜R]像装了水的气球一样",
"image": "http://sns-img-qc.xhscdn.com/73d9294a-1640-3e06-a356-79f0f90404f9?imageView2/2/w/360/format/jpg/q/75",
"link": "https://www.xiaohongshu.com/discovery/item/601bc6f10000000001001aa6",
"title": "3招拯救胸部松软没弹性📗打造挺拔胸型",
"is_star": false,
"function_entries": [
{
"type": "generate_image"
},
{
"type": "copy_link"
},
{
"type": "dislike"
},
{
"type": "report"
}
]
},
"long_press_share_info": {
"content": "",
"title": "",
"is_star": false,
"function_entries": [
{
"type": "image_download"
}
]
},
"mini_program_info": {
"user_name": "gh_52be748ce5b7",
"path": "pages/main/home/index?redirect_path=%2Fpages%2Fmain%2Fnote%2Findex%3Fid%3D601bc6f10000000001001aa6%26type%3Dnormal",
"title": "@怡倩YIQIAN 发了一篇笔记,快点来看吧!",
"desc": "⏰帮女生解决胸部烦恼的倩倩我又来啦~ 依旧是广大女生们提出来的困扰: 为什么胸部会松软干瘪,[可怜R]像装了水的气球一样",
"webpage_url": "https://www.xiaohongshu.com/discovery/item/601bc6f10000000001001aa6",
"thumb": "http://sns-img-qc.xhscdn.com/73d9294a-1640-3e06-a356-79f0f90404f9?imageView2/2/w/540/format/jpg/q/75",
"share_title": "@怡倩YIQIAN 发了一篇笔记,快点来看吧!"
},
"qq_mini_program_info": {
"user_name": "gh_66c53d495417",
"path": "pages/main/note/index?id=601bc6f10000000001001aa6&type=normal",
"title": "@怡倩YIQIAN 发了一篇超赞的笔记,快点来看!",
"desc": "⏰帮女生解决胸部烦恼的倩倩我又来啦~ 依旧是广大女生们提出来的困扰: 为什么胸部会松软干瘪,[可怜R]像装了水的气球一样",
"webpage_url": "https://www.xiaohongshu.com/discovery/item/601bc6f10000000001001aa6",
"thumb": "http://sns-img-qc.xhscdn.com/73d9294a-1640-3e06-a356-79f0f90404f9?imageView2/2/w/540/format/jpg/q/75",
"share_title": "@怡倩YIQIAN 发了一篇超赞的笔记,快点来看!"
},
"shared_count": 6,
"view_count": 0,
"has_related_goods": false,
"enable_fls_bridge_cards": false,
"enable_fls_related_cards": false,
"enable_brand_lottery": false,
"cooperate_binds": [],
"topics": [
{
"id": "58ad099e805d89755e500112",
"name": "舒服内衣推荐",
"image": "http://ci.xiaohongshu.com/17e46443-634a-480e-b8aa-4bd055bdf409@r_120w_120h.jpg",
"link": "xhsdiscover://topic/v2/5a438d93800086066171fafb?page_source=note_feed.click_new_big",
"style": 0,
"discuss_num": 0
}
],
"may_have_red_packet": false,
"has_music": false,
"head_tags": [],
"foot_tags": [
{
"id": "58ad099e805d89755e500112",
"type": 1,
"name": "舒服内衣推荐",
"link": "xhsdiscover://topic/v2/5a438d93800086066171fafb?page_source=note_feed.click_new_big"
}
],
"need_next_step": false,
"liked_users": [],
"goods_info": {},
"debug_info": "",
"use_water_color": false
}
],
"comment_list": [],
"model_type": "note"
}
]
}
这是复杂例子的java代码
public static void main(String[] args) {
// 这是一个小红书帖子的返回值
String str = "{\"code\":0,\"success\":true,\"data\":[{\"track_id\":\"\",\"user\":{\"id\":\"5b8e8d5dd2bbb00001e824eb\",\"name\":\"怡倩YIQIAN\",\"image\":\"https://sns-avatar-qc.xhscdn.com/avatar/5e8eb850e61bf20001dc3b15.jpg?imageView2/2/w/120/format/jpg\",\"followed\":false,\"red_id\":\"yiqianbra\",\"nickname\":\"怡倩YIQIAN\",\"red_official_verify_type\":0,\"show_red_official_verify_icon\":false,\"red_official_verified\":false,\"level\":{\"image\":\"\"}},\"note_list\":[{\"id\":\"601bc6f10000000001001aa6\",\"type\":\"normal\",\"title\":\"3招拯救胸部松软没弹性\uD83D\uDCD7打造挺拔胸型❗️\",\"desc\":\"⏰帮女生解决胸部烦恼的倩倩我又来啦~\\n依旧是广大女生们提出来的困扰:\\n为什么胸部会松软干瘪,[可怜R]像装了水的气球一样往下垂,胸线下移,非常不美观呢?\\n[叹气R]总是在“怎么调整胸型”、“怎么选内衣”之间碰壁,找不到真正的改善方法!\\n[皱眉R]这次科普倩倩准备了你们最关心的3个问题!\\n1、先来自测一下,自己胸部是否处于松软状态?\\n2、胸部松软,不挺拔是什么原因引起的?\\n3、胸部松软该怎么改善?\\n都整理在图片上了,记得自测一下自己胸部会不会松软!分享给身边有需要的小姐妹哦!\\n下期你们想解惑哪些困扰呢[吧唧R]\",\"hash_tag\":[],\"ats\":[],\"images_list\":[{\"fileid\":\"73d9294a-1640-3e06-a356-79f0f90404f9\",\"height\":1333,\"width\":1000,\"url\":\"http://sns-img-qc.xhscdn.com/73d9294a-1640-3e06-a356-79f0f90404f9?imageView2/2/w/1080/format/webp\",\"original\":\"http://sns-img-qc.xhscdn.com/73d9294a-1640-3e06-a356-79f0f90404f9\",\"trace_id\":\"73d9294a-1640-3e06-a356-79f0f90404f9\"},{\"fileid\":\"50919ed3-72b2-3761-9f21-5ea8d5804f1c\",\"height\":1333,\"width\":1000,\"url\":\"http://sns-img-qc.xhscdn.com/50919ed3-72b2-3761-9f21-5ea8d5804f1c?imageView2/2/w/1080/format/webp\",\"original\":\"http://sns-img-qc.xhscdn.com/50919ed3-72b2-3761-9f21-5ea8d5804f1c\",\"trace_id\":\"50919ed3-72b2-3761-9f21-5ea8d5804f1c\"},{\"fileid\":\"feb84357-e2ad-306a-b6db-bc8d94ff8d69\",\"height\":1333,\"width\":1000,\"url\":\"http://sns-img-qc.xhscdn.com/feb84357-e2ad-306a-b6db-bc8d94ff8d69?imageView2/2/w/1080/format/webp\",\"original\":\"http://sns-img-qc.xhscdn.com/feb84357-e2ad-306a-b6db-bc8d94ff8d69\",\"trace_id\":\"feb84357-e2ad-306a-b6db-bc8d94ff8d69\"},{\"fileid\":\"8fd0aaea-c243-3f2c-9429-87c5b8772271\",\"height\":1333,\"width\":1000,\"url\":\"http://sns-img-qc.xhscdn.com/8fd0aaea-c243-3f2c-9429-87c5b8772271?imageView2/2/w/1080/format/webp\",\"original\":\"http://sns-img-qc.xhscdn.com/8fd0aaea-c243-3f2c-9429-87c5b8772271\",\"trace_id\":\"8fd0aaea-c243-3f2c-9429-87c5b8772271\"},{\"fileid\":\"ad37c8f1-25f9-3d78-96cb-f499fefea669\",\"height\":1333,\"width\":1000,\"url\":\"http://sns-img-qc.xhscdn.com/ad37c8f1-25f9-3d78-96cb-f499fefea669?imageView2/2/w/1080/format/webp\",\"original\":\"http://sns-img-qc.xhscdn.com/ad37c8f1-25f9-3d78-96cb-f499fefea669\",\"trace_id\":\"ad37c8f1-25f9-3d78-96cb-f499fefea669\"},{\"fileid\":\"ebca23be-dd7f-34ca-af09-62cb92f42343\",\"height\":1333,\"width\":1000,\"url\":\"http://sns-img-qc.xhscdn.com/ebca23be-dd7f-34ca-af09-62cb92f42343?imageView2/2/w/1080/format/webp\",\"original\":\"http://sns-img-qc.xhscdn.com/ebca23be-dd7f-34ca-af09-62cb92f42343\",\"trace_id\":\"ebca23be-dd7f-34ca-af09-62cb92f42343\"},{\"fileid\":\"a80a055e-0f86-30b6-bc69-882026403856\",\"height\":1333,\"width\":1000,\"url\":\"http://sns-img-qc.xhscdn.com/a80a055e-0f86-30b6-bc69-882026403856?imageView2/2/w/1080/format/webp\",\"original\":\"http://sns-img-qc.xhscdn.com/a80a055e-0f86-30b6-bc69-882026403856\",\"trace_id\":\"a80a055e-0f86-30b6-bc69-882026403856\"},{\"fileid\":\"c9a86867-8191-37dc-8d48-956a1057ff74\",\"height\":1333,\"width\":1000,\"url\":\"http://sns-img-qc.xhscdn.com/c9a86867-8191-37dc-8d48-956a1057ff74?imageView2/2/w/1080/format/webp\",\"original\":\"http://sns-img-qc.xhscdn.com/c9a86867-8191-37dc-8d48-956a1057ff74\",\"trace_id\":\"c9a86867-8191-37dc-8d48-956a1057ff74\"},{\"fileid\":\"ade72f4d-721f-3484-97bb-0e67497d9428\",\"height\":1705,\"width\":1279,\"url\":\"http://sns-img-qc.xhscdn.com/ade72f4d-721f-3484-97bb-0e67497d9428?imageView2/2/w/1080/format/webp\",\"original\":\"http://sns-img-qc.xhscdn.com/ade72f4d-721f-3484-97bb-0e67497d9428\",\"trace_id\":\"ade72f4d-721f-3484-97bb-0e67497d9428\"}],\"user\":{\"id\":\"5b8e8d5dd2bbb00001e824eb\",\"name\":\"怡倩YIQIAN\",\"image\":\"https://sns-avatar-qc.xhscdn.com/avatar/5e8eb850e61bf20001dc3b15.jpg?imageView2/2/w/120/format/jpg\",\"followed\":false,\"red_id\":\"yiqianbra\",\"nickname\":\"怡倩YIQIAN\",\"red_official_verify_type\":0,\"show_red_official_verify_icon\":false,\"red_official_verified\":false,\"level\":{\"image\":\"\"}},\"time\":1612433137,\"last_update_time\":1612497894,\"poi\":{},\"liked\":false,\"liked_count\":533,\"collected\":false,\"collected_count\":203,\"comments_count\":21,\"sticky\":false,\"share_info\":{\"content\":\"⏰帮女生解决胸部烦恼的倩倩我又来啦~ 依旧是广大女生们提出来的困扰: 为什么胸部会松软干瘪,[可怜R]像装了水的气球一样\",\"image\":\"http://sns-img-qc.xhscdn.com/73d9294a-1640-3e06-a356-79f0f90404f9?imageView2/2/w/360/format/jpg/q/75\",\"link\":\"https://www.xiaohongshu.com/discovery/item/601bc6f10000000001001aa6\",\"title\":\"3招拯救胸部松软没弹性\uD83D\uDCD7打造挺拔胸型\",\"is_star\":false,\"function_entries\":[{\"type\":\"generate_image\"},{\"type\":\"copy_link\"},{\"type\":\"dislike\"},{\"type\":\"report\"}]},\"long_press_share_info\":{\"content\":\"\",\"title\":\"\",\"is_star\":false,\"function_entries\":[{\"type\":\"image_download\"}]},\"mini_program_info\":{\"user_name\":\"gh_52be748ce5b7\",\"path\":\"pages/main/home/index?redirect_path=%2Fpages%2Fmain%2Fnote%2Findex%3Fid%3D601bc6f10000000001001aa6%26type%3Dnormal\",\"title\":\"@怡倩YIQIAN 发了一篇笔记,快点来看吧!\",\"desc\":\"⏰帮女生解决胸部烦恼的倩倩我又来啦~ 依旧是广大女生们提出来的困扰: 为什么胸部会松软干瘪,[可怜R]像装了水的气球一样\",\"webpage_url\":\"https://www.xiaohongshu.com/discovery/item/601bc6f10000000001001aa6\",\"thumb\":\"http://sns-img-qc.xhscdn.com/73d9294a-1640-3e06-a356-79f0f90404f9?imageView2/2/w/540/format/jpg/q/75\",\"share_title\":\"@怡倩YIQIAN 发了一篇笔记,快点来看吧!\"},\"qq_mini_program_info\":{\"user_name\":\"gh_66c53d495417\",\"path\":\"pages/main/note/index?id=601bc6f10000000001001aa6&type=normal\",\"title\":\"@怡倩YIQIAN 发了一篇超赞的笔记,快点来看!\",\"desc\":\"⏰帮女生解决胸部烦恼的倩倩我又来啦~ 依旧是广大女生们提出来的困扰: 为什么胸部会松软干瘪,[可怜R]像装了水的气球一样\",\"webpage_url\":\"https://www.xiaohongshu.com/discovery/item/601bc6f10000000001001aa6\",\"thumb\":\"http://sns-img-qc.xhscdn.com/73d9294a-1640-3e06-a356-79f0f90404f9?imageView2/2/w/540/format/jpg/q/75\",\"share_title\":\"@怡倩YIQIAN 发了一篇超赞的笔记,快点来看!\"},\"shared_count\":6,\"view_count\":0,\"has_related_goods\":false,\"enable_fls_bridge_cards\":false,\"enable_fls_related_cards\":false,\"enable_brand_lottery\":false,\"cooperate_binds\":[],\"topics\":[{\"id\":\"58ad099e805d89755e500112\",\"name\":\"舒服内衣推荐\",\"image\":\"http://ci.xiaohongshu.com/17e46443-634a-480e-b8aa-4bd055bdf409@r_120w_120h.jpg\",\"link\":\"xhsdiscover://topic/v2/5a438d93800086066171fafb?page_source=note_feed.click_new_big\",\"style\":0,\"discuss_num\":0}],\"may_have_red_packet\":false,\"has_music\":false,\"head_tags\":[],\"foot_tags\":[{\"id\":\"58ad099e805d89755e500112\",\"type\":1,\"name\":\"舒服内衣推荐\",\"link\":\"xhsdiscover://topic/v2/5a438d93800086066171fafb?page_source=note_feed.click_new_big\"}],\"need_next_step\":false,\"liked_users\":[],\"goods_info\":{},\"debug_info\":\"\",\"use_water_color\":false}],\"comment_list\":[],\"model_type\":\"note\"}]}\n";
// data[0]['note_list'][0]['liked_count'] 这是用定位工具直接找到要入库的值
// 先把String对象转换成json对象
JSONObject object = JSONObject.parseObject(str);
JSONObject data = object.getJSONArray("data").getJSONObject(0);
JSONObject note_list = data.getJSONArray("note_list").getJSONObject(0);
Object liked_count = note_list.get("liked_count");
Object collected_count = note_list.get("collected_count");
System.out.println("liked_count = " + liked_count + " collected_count = " + collected_count);
}