0

When I run this code I get an error: Fatal Exception: java.lang.UnsupportedOperationException: JsonNull. What am I doing wrong?

for (i in 0 until jsonArray!!.size()) {
    val stringCode: JsonObject? = jsonArray.get(i).getAsJsonObject()
    singleUpdateArrayList!!.add(
        SingleUpdateResp(
            stringCode!!.get(TagName.AIRWAYBILLNO).getAsString(),
            stringCode.get(NotificationCompat.CATEGORY_STATUS).getAsString(),
            stringCode.get(DatabaseHandler.Companion.KEY_SYNC).getAsString()
        )
    )
}
3
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Jul 15, 2022 at 11:52
  • Maybe this answer will help you: stackoverflow.com/a/39616411/15351040 Commented Jul 15, 2022 at 12:33
  • Before using double exclamation !! If it won't come as null at the time only you've to use otherwise you've handle null's. first check your json response what are the fields,objects and arrays comes as null then verify not null Commented Jul 15, 2022 at 19:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.