Reputation: 156
I have an simple json string
{"username":"[email protected]","password":"0000"}
When I tried to read the json string using following code
JSONObject json = new JSONObject(jsonString);
Log.i(TAG,"uname "+json.getString("username"));
Log.i(TAG,"password "+json.getString("password"));
Password printing as "password 0" instead of "password 0000".
Please help me regarding this how can I read string instead of value.
Upvotes: 0
Views: 59
Reputation: 740
the value is being returned as an int. therefore the the leading 000 are cut out, essntially the same thing if you had an int 000009 returned in the json it would be converted to 9! if you want to get all chars surround the value element with quotes like this "0000". that way you will be returned all characters.
Upvotes: 1