英文:
Parse JSON from website in Java (Android)
问题
这是网址:
Json,
这是网站上的JSON:
{
"manga": {
"cover_url": "/images/manga/54666.jpg?1600241028",
"description": "\"嗨,你。\"\r\n\r\n卡萨里乌斯伯爵染上了瘟疫,突然去世,留下遗嘱,要求他试图将庄园美丽的年轻寡妇瑞塔,作为妾侍,与他一同被活埋。就在瑞塔被埋葬之前,有传言称为残酷暴君的阿克修斯大公,前来葬礼现场,以收取卡萨里乌斯伯爵仍然欠他的巨额债务。\r\n\r\n\"这里的每个人似乎都为她感到难过,而我仍然要向卡萨里乌斯收债……如果我拿她来代替债务,我想这里的所有人都应该会高兴的,\"他微笑着。\r\n\r\n\"你好,妖姬。\"",
"title": "犹如枯枝上的风",
"alt_names": ["犹如干枝上的风", "마른 가지에 바람"],
"artist": "Hwa Eum",
"author": "Moon Seaul, Uret",
"status": 1,
"demographic": 4,
"genres": [8, 13, 23, 36, 42, 44, 45],
"last_chapter": "0",
"last_volume": null,
"last_updated": 1600241253,
"lang_name": "韩文",
"lang_flag": "kr",
"hentai": 0,
"links": {
"mu": "172000",
"raw": "https://comic.naver.com/webtoon/list.nhn?titleId=748535&weekday=wed"
},
"related": [],
"rating": {
"bayesian": "8.10",
"mean": "8.50",
"users": "28"
},
"views": 5085,
"follows": 1250,
"comments": 7,
"covers": []
},
"chapter": {
"1038072": {
"volume": "",
"chapter": "1",
"title": "",
"lang_name": "英文",
"lang_code": "gb",
"group_id": 8893,
"group_name": "Why Always Scan",
"group_id_2": 0,
"group_name_2": null,
"group_id_3": 0,
"group_name_3": null,
"timestamp": 1600241253,
"comments": 20
}
},
"group": {
"8893": {
"group_name": "Why Always Scan"
}
},
"status": "OK"
}
这里我正在尝试获取文本描述,有关如何在 Java 中处理此问题有什么想法吗?
英文:
Here is the url:
The Json,
here is the JSON from the website:
{"manga":{"cover_url":"\/images\/manga\/54666.jpg?1600241028","description":""Hi, You."\r\n\r\nCount Casarius fell victim to a plague and died suddenly, leaving behind a will stating that Rietta, his beautiful young widow of the manor, whom he tried to use as a concubine, be buried alive alongside him. Just before Rietta is buried, Archduke Axias, rumored to be a cruel tyrant, arrives at the funeral to collect the enormous debt Count Casarius still owes him.\r\n\r\n"Everyone here seems to feel sorry for her, and I still have a debt to collect from Casarius… If I take her instead of debt, I think all of you here should be happy," he smiled.\r\n\r\n"Hello, Temptress."","title":"Like the Wind on a Dry Branch","alt_names":["Like a Wind on a Dry Branch","\ub9c8\ub978 \uac00\uc9c0\uc5d0 \ubc14\ub78c\ucc98\ub7fc"],"artist":"Hwa Eum","author":"Moon Seaul, Uret","status":1,"demographic":4,"genres":[8,13,23,36,42,44,45],"last_chapter":"0","last_volume":null,"last_updated":1600241253,"lang_name":"Korean","lang_flag":"kr","hentai":0,"links":{"mu":"172000","raw":"https:\/\/comic.naver.com\/webtoon\/list.nhn?titleId=748535&weekday=wed"},"related":[],"rating":{"bayesian":"8.10","mean":"8.50","users":"28"},"views":5085,"follows":1250,"comments":7,"covers":[]},"chapter":{"1038072":{"volume":"","chapter":"1","title":"","lang_name":"English","lang_code":"gb","group_id":8893,"group_name":"Why Always Scan","group_id_2":0,"group_name_2":null,"group_id_3":0,"group_name_3":null,"timestamp":1600241253,"comments":20}},"group":{"8893":{"group_name":"Why Always Scan"}},"status":"OK"}
Here I'm trying to get the text description any idea how to go around it in java ?
答案1
得分: 1
你可以使用 JSONObject 类来解析 JSON。点击此处查看参考文档
英文:
You can make use of JSONObject Class to parse json.Check this docs for reference
答案2
得分: 1
你可以使用包含在Android库中的JSON解析器。
尝试以下操作:
JSONObject jsonObject = new JSONObject(jsonString);
String textDescription = jsonObject.getString("description");
英文:
You can use the JSON parser that is included in the Android library.
Try the following:
JSONObject jsonObject = new JSONObject(jsonString);
String textDescription = jsonObject.getString("description");
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论