pokuri
pokuri

Reputation: 156

JsonObj.getString(key) returning 0 instead of 0000

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

Answers (1)

filthy_wizard
filthy_wizard

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

Related Questions