codecrazer codecrazer - 8 months ago 59
JSON Question

org.json.JSONException: Value <feed of type java.lang.String cannot be converted to JSONArray

In android studio,my code keep throwing exception and shows:
org.json.JSONException: Value

my Json is like this


the Json is very long, I just post some of it;
then some part of my java code which keep throw exception is this:

try {
JSONArray rainArray=new JSONArray(rainJSON);
int len=rainArray.length();
for (int i = 0; i < len; i++) {
JSONObject current = rainArray.getJSONObject(i);
catch(JSONException e) {
Log.e("query", "wrong in parsing the rainJSON results", e);

Thank you for your help!!

Answer Source

I finally solve my problem, I found it is because I add / to my URL, so it link to RSS, not the JSon, I just delete the / , and my app works. If someone encouter with this problem, there are three things you have to check:

  1. check if your link links to Json page
  2. check the Json page contain correct Json, correct means syntax correct
  3. realize the difference between Json object and Json array
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download