Group Group Group Group Group Group Group Group Group

Parse JSON Data | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/10376651-android-networking-fundamentals/lessons/7

I am getting the following error from this line in RemoteApi:
onTasksReceived(tasksResponse.notes ?: listOf(), null)

Elvis operator ( ?: ) always returns the left operand of non-nullable type List

It’s the only Error/Warning I get during the build, and I always get “No Data! Create Some Notes!” when I load the app.

If I add a note it shows up, but still has the “No Data” error displayed. If I log back in, no notes are displayed.

Suggestions?

Hey @dizzy49!

The warning you get is probably because the tasksResponse.notes is not-nullable, and as such the elvis never returns the right-hand side.

I’m not sure why you get the error though, are you sure you’re parsing data correctly from the server?

In the getTasks function I am using:

val tasksResponse = gson.fromJson(response.toString(), GetTasksResponse::class.java)
onTasksReceived(tasksResponse.notes ?: listOf(), null)

Which matches what was in the video.

1 Like

Hey @dizzy49 !

There’s an issue here in the video, where I add the connection.doOutput = true statement, when building the GetTasks connection.

It should only have connection.doInput = true. Let me know if this fixes your issues! Really sorry that I had missed this important part.