I have similar kind of problem. I am getting exception like JsonArray cannot be converted to Jsonobject . Can you help out on this ?
On Sat, Mar 26, 2011 at 8:21 PM, Filip Havlicek <[email protected]>wrote: > Ah, now I see, sorry I didn't notice it before. You are parsing it like > it's a String, but actually every value of a pair you have is an array, so > proper way of parsing it is something like > > JSONArray array = object.getJSONArray("login"); > for (int i=0;i<array.length();i++){ > array.getString(i)); > } > > Best regards, > Filip Havlicek > > 2011/3/26 elioncho <[email protected]> > >> Hi, >> >> Tried the get methods but still the same problem. The problems seems >> to be that the JSON array of values doesn't have a parent key that >> contains it. >> >> On Mar 25, 7:18 am, Filip Havlicek <[email protected]> wrote: >> > Hi, >> > >> > I'm using common get...() methods and they work with no problems or >> > stripping of any kind. Try to switch to get...() methods and see if that >> > makes any difference. >> > >> > Best regards, >> > Filip Havlicek >> > >> > 2011/3/24 elioncho <[email protected]> >> > >> > > Hello, >> > >> > > I'm receiving a Json response like this: >> > >> > > {"password_confirmation":["is too short (minimum is 4 >> > > characters)"],"password":["is too short (minimum is 4 >> > > characters)","doesn't match confirmation"],"email":["is too short >> > > (minimum is 6 characters)","should look like an email >> > > address."],"login":["is too short (minimum is 3 characters)","should >> > > use only letters, numbers, spaces, and .-_@ please."]} >> > >> > > I create a JSONObject with the previous string, but when I try to show >> > > the value of a key on my app I'm getting the output with brackets and >> > > quotes. >> > >> > > HttpResponse mHttpResponse = mHttpClient.execute(mHttpPost); >> > > String jsonString = EntityUtils.toString(mHttpResponse.getEntity()); >> > > try { >> > > JSONObject jsonResponse = new JSONObject(jsonString); >> > > login_edit.setError(jsonResponse.optString("login")); >> > > } >> > >> > > The optString method returns ["is too short (minimum is 3 >> > > characters)","should use only letters, numbers, spaces, and .-_@ >> > > please."]. Is this a normal thing or is something wrong in what I'm >> > > doing. Should I just strip brackets and quotes from the string? >> > >> > > Thanks, >> > >> > > ElĂas >> > >> > > -- >> > > You received this message because you are subscribed to the Google >> > > Groups "Android Developers" group. >> > > To post to this group, send email to >> [email protected] >> > > To unsubscribe from this group, send email to >> > > [email protected] >> > > For more options, visit this group at >> > >http://groups.google.com/group/android-developers?hl=en >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

