0

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

Darshan Lila
  • 5,772
  • 2
  • 24
  • 34

1 Answers1

6

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

{
  "LATITUDE1":"41",
  "LATITUDE2":"06962"
}
Simas
  • 43,548
  • 10
  • 88
  • 116
  • The problem with that: I don't have a control over the object. It is sent to me from a colleague and I can't change it because there will be other files like this. Also, the file contains 150k of these. – user37223 Aug 29 '14 at 10:04
  • @user37223 complain to your provider then. As 06962 is not a valid number and it gets automatically converted to 6962.0 or 6962. Otherwise write your own parser. As AFAIK JSON won't help you there either. – Simas Aug 29 '14 at 10:24