title: Android/Java - JSONException, java.util.HashMap cannot be converted to JSONObject API < 21
body: <p>I am running into a very strange problem on devices running API &lt; 21.</p>
  
  <p>I have the following JSONObject</p>
  
  <pre><code>{  
     "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 &amp; 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}"
  }
  </code></pre>
  
  <p>When attempting to get the JSONObject for a given day, on devices running API >= 21 I am about to use the following example code</p>
  
  <pre><code>jsonObject.getJSONObject("tuesday")
  </code></pre>
  
  <p>which successfully returns a JSONObject, however, on devices running API &lt; 21 the same exact code is throwing </p>
  
  <pre><code>Value {notes=Walk-Ins Only, open=2016-01-19T09:00:00-05:00, close=2016-01-19T18:45:00-05:00} at tuesday of type java.util.HashMap cannot be converted to JSONObject
  </code></pre>
  
  <p>Why is this happening?</p>
  
  <p>Edit: My mapping code isn't anything special - </p>
  
  <pre><code>JSONObject loungeHours = new JSONObject(ParseCloud.&lt;Map&gt;callFunction(STORE_HOURS_ENDPOINT, new HashMap&lt;String, Object&gt;()));
  </code></pre>
  
  <p>When analyzed with the debugger, loungeHours is successfully populated with the following</p>
  
  <pre><code>{  
     "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 &amp; 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}"
  }
  </code></pre>
  
  <p>Full stacktrace</p>
  
  <pre><code>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} at tuesday of type java.util.HashMap cannot be converted to JSONObject
  W/System.err:     at org.json.JSON.typeMismatch(JSON.java:100)
  W/System.err:     at org.json.JSONObject.getJSONObject(JSONObject.java:573)
  W/System.err:     at com.hitchtech.adamsbarberlounge.parse.ParseDelegate.getOpenHours(ParseDelegate.java:127)
  W/System.err:     at com.hitchtech.adamsbarberlounge.application.main.LoungeDetailFragment$LoungeInfoCardController.populateHours(LoungeDetailFragment.java:247)
  W/System.err:     at com.hitchtech.adamsbarberlounge.application.main.LoungeDetailFragment$LoungeInfoCardController.&lt;init&gt;(LoungeDetailFragment.java:105)
  W/System.err:     at com.hitchtech.adamsbarberlounge.application.main.LoungeDetailFragment.setupLoungeInfoCardController(LoungeDetailFragment.java:73)
  W/System.err:     at com.hitchtech.adamsbarberlounge.application.main.LoungeDetailFragment.onViewCreated(LoungeDetailFragment.java:64)
  W/System.err:     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
  W/System.err:     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
  W/System.err:     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
  W/System.err:     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
  W/System.err:     at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)
  W/System.err:     at android.support.v4.app.FragmentActivity.onResume(FragmentActivity.java:441)
  W/System.err:     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1185)
  W/System.err:     at android.app.Activity.performResume(Activity.java:5182)
  W/System.err:     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
  W/System.err:     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
  W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235)
  W/System.err:     at android.app.ActivityThread.access$600(ActivityThread.java:141)
  W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
  W/System.err:     at android.os.Looper.loop(Looper.java:137)
  W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5041)
  W/System.err:     at java.lang.reflect.Method.invokeNative(Native Method)
  W/System.err:     at java.lang.reflect.Method.invoke(Method.java:511)
  W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  W/System.err:     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>