https://kotlinlang.org logo
#android
Title
# android
j

Jonny

12/31/2019, 4:28 AM
So I'm trying to parse a json message. The result of the parsing is just my default initialization object.
Copy code
val gson = GsonBuilder()
    .setLenient()
    .excludeFieldsWithoutExposeAnnotation()
    .create()

val jobAcceptRequest = gson.fromJson(body, JobAcceptRequest::class.java)
The json is this:
Copy code
{
  "Id": 44,
  "SenderId": "5d2f80d3-9199-4017-a5df-1d669928a0af",
  "JobId": 13
}
And the class:
Copy code
class JobAcceptRequest {
    @Expose(serialize = false)
    var id: Int = 0
    @Expose(serialize = false)
    var senderId: String = ""
    @Expose
    var jobId: Int = 0
}
I've parsed pretty much the same thing before and it worked fine then. What's wrong here?...
i

itnoles

12/31/2019, 4:48 AM
Uppercase of I on id?
j

Jonny

12/31/2019, 5:01 AM
Hm. You are correct, the uppercase solved the issue. Weird because I was pretty sure that I was sending uppercase before as well. I'll have to look into handling that then, thank you!