/ / Androidで封印された文字列をjsonオブジェクトに変換する方法-json

Androidでjearオブジェクトにseralized文字列を変換する方法-json

以下のコードは私のJSONファイルであり、サーバーからこのデータを読み取りたいので、AndroidでJSONObjectを使用してこれらのデータを読み取るにはどうすればよいですか?

このコードには、配列の名前識別子なしでそれ自体で始まる配列識別子が含まれています


[
{
"created_at": "Sat Nov 10 12:00:26 +0000 2012",
"id": 267235264374640640,
"id_str": "267235264374640640",
"text": "My text",
"user": {
"id": 166551306,
"id_str": "166551306",
"name": "John ",
"location": "Chennai, India",
"url": null,
"notifications": null
},
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"retweet_count": 0,
"entities": {
"hashtags": [],
"urls": [],
"user_mentions": []
},
"favorited": false,
"retweeted": false
},
{
"created_at": "Sat Nov 10 12:00:26 +0000 2012",
"id": 267235264374640640,
"id_str": "267235264374640640",
"text": "My text",
"user": {
"id": 166551306,
"id_str": "166551306",
"name": "John ",
"location": "Chennai, India",
"url": null,
"notifications": null
},
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"retweet_count": 0,
"entities": {
"hashtags": [],
"urls": [],
"user_mentions": []
},
"favorited": false,
"retweeted": false
},
]

回答:

回答№1は1

あなたはこれを直接読むことができます JSONArray ない JSONObject

JSONArray jsonArray = new JSONArray(dataString);

提供されたJSONデータで試してみましたが、正常に機能しました。