java.lang.ClassCastException: org.json.JSONObject$1 cannot be cast to java.lang.String binding the statement
See original GitHub issueHi,
I’m receiving a JSON with the following format:
{"TICKET_ID":"1","ACCOUNT_ID":null,"TICKET_REF":null, ..a lot of stuff here.......}
but when I call jsonModel.save(). I’m getting the following exception:
02-23 16:51:06.085 7205-7536/com.glownet.app.staging.debug D/Retrofit﹕ java.lang.ClassCastException: org.json.JSONObject$1 cannot be cast to java.lang.String
at com.glownet.app.glownet.entities.Admission$Container.bindToStatement(Admission$Container.java:46)
at com.glownet.app.glownet.entities.Admission$Container.bindToStatement(Admission$Container.java:16)
at com.raizlabs.android.dbflow.sql.SqlUtils.insert(SqlUtils.java:378)
at com.raizlabs.android.dbflow.sql.SqlUtils.save(SqlUtils.java:316)
at com.raizlabs.android.dbflow.structure.container.ContainerAdapter.save(ContainerAdapter.java:36)
at com.raizlabs.android.dbflow.structure.container.BaseModelContainer.save(BaseModelContainer.java:126)
Because in the Model$Cointainer the following check is created:
if (((java.lang.String)modelContainer.getValue("TICKET_REF")) != null) {
statement.bindString(1,((java.lang.String)modelContainer.getValue("TICKET_REF")));
A JSONObject.NULL is being tried to be converted to String with the cast.
How should I proceed?
The ticket ref is not a PK.
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
java.lang.ClassCastException: org.json.JSONObject$1 cannot ...
org.json.JSONObject$1 cannot be cast to org.json.JSONObject seems that object is of type JSONObject$1 and its refer this object to JSONObject..
Read more >java.lang.String cannot be cast to org.json.simple.JSONObject
Solved: I have a requirement to generate a RITM by copying Variables into new RITM. var gr = new GlideRecord("sc_req_item"); if.
Read more >ClassCastException "Java.Lang.String Cannot Be Cast To ...
Oracle JDeveloper - Version 12.2.1.2.0 and later: ClassCastException "Java.Lang.String Cannot Be Cast To " When Using af:dynamicComponent.
Read more >"org.json.simple.JSONObject cannot be cast to java ... - ERROR
ERROR: "org.json.simple.JSONObject cannot be cast to java.lang.String error" while importing a cluster configuration in Administrator Console ...
Read more >openHAB Cloud "class org.json.JSONObject cannot be cast to ...
2022-08-08 14:47:31.816 [ERROR] [io.socket.thread.EventThread ] - Task threw exception java.lang.ClassCastException: class org.json.JSONObject ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Its a bug. Good find. Best bet until I release 1.6.0 (probably tomorrow) is to subclass
JSONModel
and override this way:JSONObject wraps
null
values in aNULL
object.version 1.6.0 is now out