Я столкнулся с этим знакомым исключением при разработке приложения для Android
Нет значения для сообщения
И я уверен, что JSONObject, который у меня есть, содержит то, что я ищу:
вот мой объект JSON, и вы можете отформатировать его, чтобы лучше понять его здесь:http://jsonformatter.curiousconcept.com/< /а>
{
"data": [
{
"id": "1438734076389483_1440132306249660",
"from": {
"category": "Community",
"name": "AKA",
"id": "14387376389483"
},
"message": "TEST TEST",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/14387340769483/posts/14401323069660"
},
{
"name": "Like",
"link": "https://www.facebook.com/14387376389483/posts/14402306249660"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "status",
"status_type": "mobile_status_update",
"created_time": "2014-07-14T18:49:43+0000",
"updated_time": "2014-07-14T18:49:43+0000",
"likes": {
"data": [
{
"id": "84207420",
"name": "Akira Yuki"
},
{
"id": "14387346389483",
"name": "AKA"
}
],
"paging": {
"cursors": {
"after": "MTQzODczNDA3NjM4OTQ4Mw==",
"before": "ODQyMDQ3NDIw"
}
}
}
},
{
"id": "1438734076389483_14399988596342",
"from": {
"category": "Community",
"name": "AKA",
"id": "1438734076389483"
},
"message": "MEssage test number twooooo",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/143873076389483/posts/143999881956342"
},
{
"name": "Like",
"link": "https://www.facebook.com/143873076389483/posts/143999819596342"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "status",
"status_type": "mobile_status_update",
"created_time": "2014-07-14T10:58:20+0000",
"updated_time": "2014-07-14T10:58:20+0000"
},
{
"id": "143873476389483_1439998362929721",
"from": {
"category": "Community",
"name": "AKA",
"id": "1438734076389483"
},
"message": "Never give up",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/143873406389483/posts/143999836292721"
},
{
"name": "Like",
"link": "https://www.facebook.com/143873076389483/posts/139998362929721"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "status",
"status_type": "mobile_status_update",
"created_time": "2014-07-14T10:55:16+0000",
"updated_time": "2014-07-14T10:55:16+0000"
},
{
"id": "1438734076389483_1439998316263059",
"from": {
"category": "Community",
"name": "AKA",
"id": "1438734076389483"
},
"message": "lemme try",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/143873476389483/posts/143998316263059"
},
{
"name": "Like",
"link": "https://www.facebook.com/143734076389483/posts/143998316263059"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "status",
"status_type": "mobile_status_update",
"created_time": "2014-07-14T10:54:54+0000",
"updated_time": "2014-07-14T10:54:54+0000"
},
{
"id": "143873407639483_1439990399597184",
"from": {
"category": "Community",
"name": "AKA",
"id": "143873407389483"
},
"message": "AAAAAAAAAAAAAAA BBBBBBBBBBBBBBB",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/143734076389483/posts/143990399597184"
},
{
"name": "Like",
"link": "https://www.facebook.com/143734076389483/posts/143999039957184"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "status",
"status_type": "mobile_status_update",
"created_time": "2014-07-14T10:12:51+0000",
"updated_time": "2014-07-14T10:12:51+0000"
},
{
"id": "143873407689483_143998952930603",
"from": {
"category": "Community",
"name": "AKA",
"id": "1438734076389483"
},
"message": "hello",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/143734076389483/posts/14399895420603"
},
{
"name": "Like",
"link": "https://www.facebook.com/143873407638483/posts/143989542930603"
}
],
"privacy": {
"description": "Public",
"value": "EVERYONE",
"friends": "",
"networks": "",
"allow": "",
"deny": ""
},
"type": "status",
"status_type": "mobile_status_update",
"created_time": "2014-07-14T10:05:09+0000",
"updated_time": "2014-07-14T10:05:09+0000"
}
],
"paging": {
"previous": "https://graph.facebook.com/v2.0/143873476389483/feed?limit=25&since=140363783",
"next": "https://graph.facebook.com/v2.0/143873406389483/feed?limit=25&until=140532308"
}
}
И ВОТ МОЙ КОД, КОТОРЫЙ ВЫДАЕТ ИСКЛЮЧЕНИЕ
JSONObject oneRowJSONObj = response
.getGraphObject()
.getInnerJSONObject();
JSONArray dataJSONArray = oneRowJSONObj
.getJSONArray("data");
Log.v(TAG, dataJSONArray.toString());
//Working
for (int i = 0; i < dataJSONArray.length() ; i++) {
JSONObject c = dataJSONArray
.getJSONObject(i);
// Storing JSON item in a Variable
String message = c.getString("message");
Log.v("ONE ROW", message);//Here i get the exception