Android : JSONObject getstring removes the zero from string

on Friday, August 29, 2014


I'm trying to get numerical values that start with "0"s from a JSONObject. The problem is the method converts the string into a double. Example:


JSONObject:



{
"LATITUDE1":41,
"LATITUDE2":06962
}


When I use



String lat2 = object.getString("LATITUDE2");


the String lat2 is displayed as "6962.0". How can I make it so that the string is displayed as it is in the json file (as "06962")?


I will then need to concatenate the two values and add a dot in between them to get a decimal number such as 41.06962 that's why I need to get the values as strings.


Thanks


0 comments:

Post a Comment