Note that there are some explanatory texts on larger screens.

plurals
  1. POJava JSONException while creating JSONArray
    primarykey
    data
    text
    <p>I am facing <code>JSONException</code> while creating a <code>JSONArray</code> from of a string. I have validated the response string from Webservice using JSON Validator.</p> <p>here is the code:</p> <pre><code>json = new JSONObject(); content = recieveData(json.toString(), m_sTimeTableUrl + sPGId); if (content != null){ Log.d(TAG, "got content:"+content); try { JSONArray jArray2 = new JSONArray(content); //THE EXCEPTION FIRES HERE! Log.i(TAG, "Number of entries " + jArray2.length()); Happening pHappening = null; ArrayList&lt;Happening&gt; pResult = new ArrayList&lt;Happening&gt;(); for(int i = 0; i &lt; jArray2.length(); i++){ pHappening = new Happening(); JSONObject jObject = jArray2.getJSONObject(i); pHappening.setEndtime(new Time(jObject.getInt("EndMinute"))); pHappening.setDocent(jObject.getString("Lecturer")); pHappening.setRoom(jObject.getString("Room")); pHappening.setStartTime(new Time(jObject.getInt("StartMinute"))); pHappening.setName(jObject.getString("Title")); pHappening.setDayOfWeek(jObject.getInt("Weekday")); pResult.add(pHappening); } //java.util.Arrays.sort(pResult); return pResult; }catch (JSONException e) { Log.e(TAG, e.toString()); } </code></pre> <p>and this is how my content string looks like:</p> <pre><code>{ "Happenings" : [ { "EndMinute" : 570, "Lecturer" : "Prof. Dr. Christian Schrödter", "OrgLecturId" : 10181, "Room" : "KC112", "StartMinute" : 480, "Title" : "Physik 1 (310321) ", "Weekday" : 0 }, { "EndMinute" : 675, "Lecturer" : "Prof. Dr.-Ing. Norbert Wellerdick", "OrgLecturId" : 1750, "Room" : "KD010", "StartMinute" : 585, "Title" : "TM 1 (310341) ", "Weekday" : 0 }, { "EndMinute" : 780, "Lecturer" : "Prof. Dr. Christian Schrödter", "OrgLecturId" : 10181, "Room" : "KC112", "StartMinute" : 690, "Title" : "Physik 1 (310321) ", "Weekday" : 0 }, { "EndMinute" : 930, "Lecturer" : "Prof. Dr. Christian Schrödter; Dipl.-Ing. (FH) Bernd Bleyel", "OrgLecturId" : 1742, "Room" : "KA303", "StartMinute" : 840, "Title" : "Info 1 (310351) ", "Weekday" : 0 }, { "EndMinute" : 570, "Lecturer" : "Prof. Dr.-Ing. Hermann Lanfer", "OrgLecturId" : 1753, "Room" : "KC133", "StartMinute" : 480, "Title" : "ET 1 (310331) ", "Weekday" : 1 }, { "EndMinute" : 675, "Lecturer" : "Prof. Dr. Christian Schrödter; Dipl.-Ing. (FH) Bernd Bleyel", "OrgLecturId" : 1742, "Room" : "KA303", "StartMinute" : 585, "Title" : "Info 1 (310351) ", "Weekday" : 1 }, { "EndMinute" : 780, "Lecturer" : "Prof. Dr.-Ing. Axel Schenk", "OrgLecturId" : 1812, "Room" : "KD010", "StartMinute" : 690, "Title" : "Mathe 1 (310311) ", "Weekday" : 1 }, { "EndMinute" : 570, "Lecturer" : "Prof. Dr. Christian Schrödter", "OrgLecturId" : 8357, "Room" : "KC112", "StartMinute" : 480, "Title" : "Info 1 (310351) ", "Weekday" : 2 }, { "EndMinute" : 675, "Lecturer" : "Prof. Dr.-Ing. Hermann Lanfer", "OrgLecturId" : 1753, "Room" : "KC112", "StartMinute" : 585, "Title" : "ET 1 (310331) ", "Weekday" : 2 }, { "EndMinute" : 780, "Lecturer" : "Prof. Dr.-Ing. Robert Paspa", "OrgLecturId" : 1764, "Room" : "KC112", "StartMinute" : 690, "Title" : "Konstruk.1 (310381) ", "Weekday" : 2 }, { "EndMinute" : 930, "Lecturer" : "Prof. Dr.-Ing. Axel Schenk", "OrgLecturId" : 1812, "Room" : "KC112", "StartMinute" : 840, "Title" : "Mathe 1 (310311) ", "Weekday" : 2 }, { "EndMinute" : 570, "Lecturer" : "Birgitta Götzelmann-Liebig", "OrgLecturId" : 8324, "Room" : "KC113", "StartMinute" : 480, "Title" : "TechEngl1 (310391) ", "Weekday" : 3 }, { "EndMinute" : 675, "Lecturer" : "Birgitta Götzelmann-Liebig", "OrgLecturId" : 8324, "Room" : "KC113", "StartMinute" : 585, "Title" : "TechEngl1 (310391) ", "Weekday" : 3 }, { "EndMinute" : 780, "Lecturer" : "Prof. Dr.-Ing. Hermann Lanfer", "OrgLecturId" : 1753, "Room" : "KD010", "StartMinute" : 690, "Title" : "ET 1 (310331) ", "Weekday" : 3 }, { "EndMinute" : 930, "Lecturer" : "Prof. Dr.-Ing. Axel Schenk", "OrgLecturId" : 1812, "Room" : "KD010", "StartMinute" : 840, "Title" : "Mathe 1 (310311) ", "Weekday" : 3 } ] } </code></pre> <p>Looking forward for some help !</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload