У меня есть JSON строку, как это:JSON синтаксический с JSONObject не работает
{
"ip":"10.41.X.X",
"board":
{
"projets":{},
"notes":{},
"susies":{},
"activites":{},
"modules":{},
"stages":{},
"tickets":{}
}
"history":
{
{
"title":"You have joined the activity Corrections Evaluation - M\u00e9mo professionnel<\/a>"
"user":
{
"picture":"https:\/\/cdn.local.epitech.eu\/userprofil\/amsell_j.bmp",
"title":"Jeremie Amsellem",
"url":"\/user\/amsell_j\/"
},
"content":"Remember to validate your presence with your token View other registered people ...<\/a>", "date":"2014-11-23 18:24:42",
"id":"6557808",
"visible":"1",
"id_activite":"173479",
"class":"register"
}
}
"infos":
{
"id":"42891",
"login":"amsell_j",
"title":"Jeremie Amsellem",
"email":null, "internal_email":"[email protected]",
"lastname":"Amsellem",
"firstname":"Jeremie",
"userinfo":{}
"referent_used":true,
"picture":"amsell_j.bmp",
"picture_fun":null,
"email_referent":"[email protected]",
"pass_referent":"0000",
"promo":2017,
"semester":5,
"uid":110268,
"gid":32017,
"location":"FR\/PAR",
"documents":"vrac\/amsell_j",
"userdocs":"\/u\/epitech_2017\/amsell_j\/cu",
"shell":"\/usr\/site\/bin\/shell",
"netsoul":null,
"close":false,
"close_reason":null,
"ctime":"2013-12-06 04:00:56",
"mtime":"2013-11-22 18:00:05",
"comment":null,
"id_promo":"279",
"id_history":"144269",
"course_code":"bachelor\/classic",
"school_code":"epitech",
"school_title":"epitech",
"old_id_promo":"244,250,255,254,272",
"old_id_location":"4",
"rights":{ },
"invited":true,
"studentyear":3,
"admin":false,
}
"current":
{
"active_log":"0.9069",
"credits_min":"120",
"credits_norm":"120",
"credits_obj":"150",
"nslog_min":"15",
"nslog_norm":"25",
"semester_code":"B5",
"semester_num":"5",
"achieved":124,
"failed":63,
"inprogress":39
}
}
И я хочу, чтобы восстановить строку в «картинке» под «историей». Я сделал следующий код, но он не работает:
JSONObject jsonObject = new JSONObject(toParse);
JSONObject history = jsonObject.getJSONObject("history");
Log.d("test", history.getString("title"));
И если я сделаю это, например, что он работает, хорошо отображается идентификатор:
JSONObject jsonObject = new JSONObject(toParse);
JSONObject history = jsonObject.getJSONObject("infos");
Log.d("test", history.getString("id"));
У вас есть представление о том, почему это не за работой ?
В вашем json отсутствуют запятые между объектами. – dharms
title - свойство объекта, вложенного в объект истории, почему у вас есть дополнительные скобки? – JimW
Полученный json дает API моей школы, и мне нужно восстановить путь к картинке в «истории». API находится здесь: http://epitech-api.herokuapp.com/ –