0

Possible Duplicate:
Parse JSON object with string and value only
How to parse JSON in JavaScript

How can I parse such json?

"prices":{"2":"800.0", "8":"580.0", "5":"657.0"}

Usually I do it in this way:

object.getInt("id")

But now I don't know previously what int I get. In example there are 2,8,5, but they can be another..

Thanks in advance.

Here is answer

Community
  • 1
  • 1
Alex Zaitsev
  • 2,013
  • 4
  • 30
  • 56
  • not sure about the phrase "what int I get". Are you trying to get the integer value from the json string? If yes, Why dont you just use object.getString() and then cast the type to int? – Thai Tran Aug 16 '12 at 07:55
  • @ThaiTran I need to parse this: "2":"800.0", "8":"580.0", "5":"657.0" ! The first number is id, the second - value. The ids are always different! The only way I know is cast JSONObject to string and parse string but maybe there is better way. – Alex Zaitsev Aug 16 '12 at 08:05

1 Answers1

0

You need a JSON library for Java.

Paul Jowett
  • 6,513
  • 2
  • 24
  • 19