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.
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
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