Go Back   Android Forums > Android Discussion > Android Applications
Android Applications All the information you could ever want about Android Applications. Learn about apps and get help with them... all here! New apps can be found and announced in the Applications Announcements forum linked below.

Find everything you need for the Galaxy S5 and discuss it in our S5 forum!
Have you seen that OnePlus One's awesome camera?? The forum is over here!

test: Reply
 
LinkBack Thread Tools
Old March 23rd, 2011, 11:33 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Nov 2010
Posts: 3
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default JSONObject optString output

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.


Code:
 
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

elioncho is offline  
Reply With Quote
sponsored links
Reply
Tags
json, optstring


Go Back   Android Forums > Android Discussion > Android Applications
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:40 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.