Null pointer exception json parsing url android -


I am trying to parse the json entry from the url. Below is the code section.

  TextView txtViewParsedValue; Private JSONObject jsonObject; Private Static String URL = "https://www.dropbox.com/s/rhk01nqlyj5gixl/jsonparsing.txt?dl=1"; String strparsedValue = null; TextView txtViewParsedValue; Private JSONObject jsonObject; Private Static String URL = "https://www.dropbox.com/s/rhk01nqlyj5gixl/jsonparsing.txt?dl=1"; String strparsedValue = null; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); SetContentView (R.layout.activity_main); TxtViewParsedValue = (TextView) findViewById (R.id.textview1); Try {parseJSON (); } Grip (JasonAxpection E) {// Two-Auto Auto-Generated Cat Block E.Pintstaxtres (); }} Public Zero ParseJSON () throws JSONException {JSONParser jParser = new JSONParser (); JsonObject = jParser.getJSONFromUrl (url); JSONObject object = jsonObject.getJSONObject ("student"); JSONArray subArray = object.getJS ONArray ("student"); (Int i = 0; i & lt; subArray.length (); i ++) {strParsedValue + = "\ n" + SubArte.GetJSen Object (i) .getString ("id"). ToString (); } TxtViewParsedValue.setText (strParsedValue); }   

I want to remove all student IDs and print them in textview. With its blank pointer exception, it examined it and tried to do it, but did not work, no guidance would be very helpful!

student is instead of JsonArray > JsonObject but you are trying to get it as JsonObject . Change your parsing code to:

  JSONArray subArray = jsonObject.getJSONArray ("student"); // & lt; & Lt; & Lt; Student for JSONArray (int i = 0; i & lt; subArray.length (); i ++) {strParsedValue + = "\ n" + subArray.getJSON object (i) .getString ("id"). ToString (); }    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -