A attenzi0ne Member Licensed User Longtime User Feb 28, 2015 #1 Hello evryone I have a jar that returns a JSONObject (org.json.JSONObject) how am I supposed to handle this return? I tried casting it directly into a map but I get Code: java.lang.ClassCastException: org.json.JSONObject cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap any help will be appreciated
Hello evryone I have a jar that returns a JSONObject (org.json.JSONObject) how am I supposed to handle this return? I tried casting it directly into a map but I get Code: java.lang.ClassCastException: org.json.JSONObject cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap any help will be appreciated
DonManfred Expert Licensed User Longtime User Feb 28, 2015 #2 You need provide more code i believe What i can see is that you are trying to use this jsonobject a a map. But without seeing more code it is hard to help Upvote 0
You need provide more code i believe What i can see is that you are trying to use this jsonobject a a map. But without seeing more code it is hard to help
A attenzi0ne Member Licensed User Longtime User Feb 28, 2015 #3 Hello again This is the code: Code: Dim c_worker As cls_fetcher log(c_worker.f_get_results) in the console this is what I see after executing that code Code: (MyMap) {.section=9, signal-strength=-79} so I assumed "f_get_results" is returning a Map and I did this: Code: Dim c_worker As cls_fetcher Dim t_map As Map = c_worker.f_get_results but unfortunately I got this error message: Code: java.lang.ClassCastException: org.json.JSONObject cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap so my question is, how am I supposed to handle the java JSONObject object in b4a? thanks again Upvote 0
Hello again This is the code: Code: Dim c_worker As cls_fetcher log(c_worker.f_get_results) in the console this is what I see after executing that code Code: (MyMap) {.section=9, signal-strength=-79} so I assumed "f_get_results" is returning a Map and I did this: Code: Dim c_worker As cls_fetcher Dim t_map As Map = c_worker.f_get_results but unfortunately I got this error message: Code: java.lang.ClassCastException: org.json.JSONObject cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap so my question is, how am I supposed to handle the java JSONObject object in b4a? thanks again
S Sub7 Active Member Licensed User Longtime User Feb 28, 2015 #4 I had similar problem, i converted it to string and the parsed in this way, not sure if this can help and if it is the best way. Code: Dim theJson As String = your jsonobject Dim json As JSONParser Dim map_01 As Map map_01.Initialize json.Initialize(theJson) map_01 = json.NextObject log(map_01.Get("fieldname")) Upvote 0
I had similar problem, i converted it to string and the parsed in this way, not sure if this can help and if it is the best way. Code: Dim theJson As String = your jsonobject Dim json As JSONParser Dim map_01 As Map map_01.Initialize json.Initialize(theJson) map_01 = json.NextObject log(map_01.Get("fieldname"))