如何在java String中获得RATE的值

时间:2014-09-13 07:43:11

标签: java android json string

{
"query":{
  "count":1,
  "created":"2014-09-13T07:32:01Z",
  "lang":"en-US",
  "results":{  
     "rate":{  
        "id":"USDINR",
        "Name":"USD to INR",
        "Rate":"60.8075",
        "Date":"9/13/2014",
        "Time":"3:23am",
        "Ask":"60.815",
        "Bid":"60.80"
     }
  }
}
}

我想得到RATE的值60.80754 在JAVA中的字符串请帮助

由于

1 个答案:

答案 0 :(得分:2)

试试这个..

JSONObject obj = new JSONObject(string);
JSONObject query = obj.getJSONObject("query");
JSONObject results = query.getJSONObject("results");
JSONObject rate_obj = results.getJSONObject("rate");
String Rate = rate_obj.getString("Rate");