In my Android application I want to use google currency converter. Google currency converter outputs result in a json format like:
{lhs: "1 British pound",rhs: "1.6058 U.S. dollars",error: "",icc: true}
I used following code stub in my Android application to get the output from json
JSONArray jArray = new JSONArray(jsonResult);
JSONObject json_data=null;
String currency01 = "";
String currency02 = "";
for(int i=0;i<jArray.length();i++){
json_data = jArray.getJSONObject(i);
c1 = json_data.getString("lhs");
c2 =json_data.getString("rhs");
tv.append(c1+"\n\n");
tv.append(c2);
}
but this doesn’t give any result no errors also. Please help I’m stuck here how to read above json in Andoid.
Thanks in advance.
Use this as you are not getting array its json object
I have tested using url http://www.google.com/ig/calculator?hl=en&q=1GBP=?USD