7
I have a url that gives me the data in this format:
{"to": "DKK", "rate": 7.4417, "from": "EUR"}
I’m trying to read them this way:
JSONObject obj = new JSONObject();
JSONObject obj2 = obj.getJSONObject(site);
String to = (String)obj2.get("to");
Double rate = obj2.getDouble("rate");
ERROR:
org.json.Jsonexception: No value for http://rate-exchange-1.appspot.com/currency?from=EUR&to=DKK 04-22 23:06:56.114 19331-19991/com.converter.android.converter W/System.err: at org.json.Jsonobject.get(Jsonobject.java:389) 04-22 23:06:56.114 19331-19991/com.converter.android.converter W/System.err: at org.json.Jsonobject.getJSONObject(Jsonobject.java:609) 04-22 23:06:56.114 19331-19991/com.converter.android.converter W/System.err: at com.converter.android.converter.Convertactivity$Parse.doInBackground(Convertactivity.java:1579) 04-22 23:06:56.114 19331-19991/com.converter.android.converter W/System.err: at com.converter.android.converter.Convertactivity$Parse.doInBackground(Convertactivity.java:1547) 04-22 23:06:56.114 19331-19991/com.converter.android.converter W/System.err: at android.os.Asynctask$2.call(Asynctask.java:295) 04-22 23:06:56.114 19331-19991/com.converter.android.converter W/System.err: at java.util.current.FutureTask.run(Futuretask.java:237) 04-22 23:06:56.114 19331-19991/com.converter.android.converter W/System.err: at android.os.Asynctask$Serialexecutor$1.run(Asynctask.java:234) 04-22 23:06:56.114 19331-19991/com.converter.android.converter W/System.err: at java.util.current.ThreadPoolExecutor.runWorker(Threadpoolexecutor.java:1113) 04-22 23:06:56.114 19331-19991/com.converter.android.converter W/System.err: at java.util.Concurrent.Threadpoolexecutor$Worker.run(Threadpoolexecutor.java:588) 04-22 23:06:56.114 19331-19991/com.converter.android.converter W/System.err: at java.lang.Thread.run(Thread.java:818)
Can someone help me?
Thank you! It worked!
– porthfind