user37223
user37223

Reputation: 1

JSONObject getstring removes the zero from string

I'm trying to get numerical values that start with 0s 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

Upvotes: 0

Views: 733

Answers (1)

Simas
Simas

Reputation: 44158

If it's a string let it be a string:

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

Upvotes: 6

Related Questions