Code example for JSONTokener

Methods: nextValue

0
		abstract protected void onDownloadJsonComplete(Object object) throws JSONException;
		 
		// Parse the text response into JSON 
		@Override 
		protected final void onDownloadComplete(String str) {
			JSONTokener tokener = new JSONTokener(str);
			try { 
				Object object = tokener.nextValue();
				if (object instanceof JSONObject) {
					onDownloadJsonComplete(object);
				} 
				else if (object instanceof JSONArray) {
					onDownloadJsonComplete(object);
				} 
				else { 
					onError("JSON response is an unexpected data type"); 
				} 
			} catch (JSONException e) {
				onError("JSONException while parsing response: " + e.getLocalizedMessage());
			} 
		}