Loading...
Logo
Processing Forum
Hey all, sorry if this is a dumb question, I am trying to get some JSON data, below is an example of my code, this is running inside a method, reading the data doesnt throw an exception by when I try to retrieve it I get "the method getString(int) in the type JSONArray is not applicable for the arguements (string)" however the data I am trying to get is a string. I thought it was because the first data pair includes string and int values but I have tried running it on the author string value and I get the same thing - I have included an example of the data below. Any help appreciated

o = entries.getJSONObject(i);
             
              parentArray = split(e.getString("parents"), ",");
              r.p1 = int("parentArray[1]");
              r.p2 = int("parentArray[2]");
              r.author = e.getString("author");
              String date = e.getString("date");
              r. message = e.getString("message");


{
      "parents": [
        [
          "57fa0370d1caf504062b059ca538b305b518ac83",
          2160,
          7
        ]
      ],
      "author": "zach gage",
      "time": 2196,
      "id": "4db2c27263f69561410e01a630a6458db401eff2",
      "date": "2011-01-14 20:19:33",
      "gravatar": "b089227a1748a2d70cdfc4ef00b325ad",
      "space": 7,
      "message": "ofxiPhoneVideoGrabber implemented",
      "login": "stfj"
    },



Replies(2)

I moved this to the Contributed Libraries Questions section, although you omitted to tell us what library you use (I know at least half a dozen of Json libraries for Java...).

" "the method getString(int) in the type JSONArray is not applicable for the arguements (string)" however the data I am trying to get is a string"
Indeed, that's what the message is telling you: you feed a method with a string while it wants an int (perhaps an index?).
Can't tell you much more, as we don't even see what e can be (a JSONArray?).
Yeh, sorry, I am pretty new to all this, and you're right, I was calling from the array object instead of the object inside the array 
thanks for your help