json - Android/Java - JSONException, java.util.HashMap cannot be converted to JSONObject API < 21 -
i running strange problem on devices running api < 21.
i have following jsonobject
{ "saturday":"{notes=walk-ins only, open=2016-01-16t08:00:00-05:00, close=2016-01-16t15:00:00-05:00}", "wednesday":"{notes=walk-ins only, open=2016-01-20t09:00:00-05:00, close=2016-01-20t18:45:00-05:00}", "tuesday":"{notes=walk-ins only, open=2016-01-19t09:00:00-05:00, close=2016-01-19t18:45:00-05:00}", "friday":"{notes=walk-ins only, open=2016-01-22t09:00:00-05:00, close=2016-01-22t18:45:00-05:00}", "thursday":"{notes=appointments & walk-ins, open=2016-01-21t09:00:00-05:00, close=2016-01-21t18:45:00-05:00}", "monday":"{notes=null, open=null, close=null}", "sunday":"{notes=null, open=null, close=null}" }
when attempting jsonobject given day, on devices running api >= 21 use following example code
jsonobject.getjsonobject("tuesday")
which returns jsonobject, however, on devices running api < 21 same exact code throwing
value {notes=walk-ins only, open=2016-01-19t09:00:00-05:00, close=2016-01-19t18:45:00-05:00} @ tuesday of type java.util.hashmap cannot converted jsonobject
why happening?
edit: mapping code isn't special -
jsonobject loungehours = new jsonobject(parsecloud.<map>callfunction(store_hours_endpoint, new hashmap<string, object>()));
when analyzed debugger, loungehours populated following
{ "saturday":"{notes=walk-ins only, open=2016-01-16t08:00:00-05:00, close=2016-01-16t15:00:00-05:00}", "wednesday":"{notes=walk-ins only, open=2016-01-20t09:00:00-05:00, close=2016-01-20t18:45:00-05:00}", "tuesday":"{notes=walk-ins only, open=2016-01-19t09:00:00-05:00, close=2016-01-19t18:45:00-05:00}", "friday":"{notes=walk-ins only, open=2016-01-22t09:00:00-05:00, close=2016-01-22t18:45:00-05:00}", "thursday":"{notes=appointments & walk-ins, open=2016-01-21t09:00:00-05:00, close=2016-01-21t18:45:00-05:00}", "monday":"{notes=null, open=null, close=null}", "sunday":"{notes=null, open=null, close=null}" }
full stacktrace
w/system.err: org.json.jsonexception: value {notes=walk-ins only, open=2016-01-19t09:00:00-05:00, close=2016-01-19t18:45:00-05:00} @ tuesday of type java.util.hashmap cannot converted jsonobject w/system.err: @ org.json.json.typemismatch(json.java:100) w/system.err: @ org.json.jsonobject.getjsonobject(jsonobject.java:573) w/system.err: @ com.hitchtech.adamsbarberlounge.parse.parsedelegate.getopenhours(parsedelegate.java:127) w/system.err: @ com.hitchtech.adamsbarberlounge.application.main.loungedetailfragment$loungeinfocardcontroller.populatehours(loungedetailfragment.java:247) w/system.err: @ com.hitchtech.adamsbarberlounge.application.main.loungedetailfragment$loungeinfocardcontroller.<init>(loungedetailfragment.java:105) w/system.err: @ com.hitchtech.adamsbarberlounge.application.main.loungedetailfragment.setuploungeinfocardcontroller(loungedetailfragment.java:73) w/system.err: @ com.hitchtech.adamsbarberlounge.application.main.loungedetailfragment.onviewcreated(loungedetailfragment.java:64) w/system.err: @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1086) w/system.err: @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1248) w/system.err: @ android.support.v4.app.backstackrecord.run(backstackrecord.java:738) w/system.err: @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1613) w/system.err: @ android.support.v4.app.fragmentcontroller.execpendingactions(fragmentcontroller.java:330) w/system.err: @ android.support.v4.app.fragmentactivity.onresume(fragmentactivity.java:441) w/system.err: @ android.app.instrumentation.callactivityonresume(instrumentation.java:1185) w/system.err: @ android.app.activity.performresume(activity.java:5182) w/system.err: @ android.app.activitythread.performresumeactivity(activitythread.java:2732) w/system.err: @ android.app.activitythread.handleresumeactivity(activitythread.java:2771) w/system.err: @ android.app.activitythread.handlelaunchactivity(activitythread.java:2235) w/system.err: @ android.app.activitythread.access$600(activitythread.java:141) w/system.err: @ android.app.activitythread$h.handlemessage(activitythread.java:1234) w/system.err: @ android.os.handler.dispatchmessage(handler.java:99) w/system.err: @ android.os.looper.loop(looper.java:137) w/system.err: @ android.app.activitythread.main(activitythread.java:5041) w/system.err: @ java.lang.reflect.method.invokenative(native method) w/system.err: @ java.lang.reflect.method.invoke(method.java:511) w/system.err: @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) w/system.err: @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) w/system.err: @ dalvik.system.nativestart.main(native method)
Comments
Post a Comment