I am trying to convert ArrayList of custom class to JsonArray. Below is my code. It executes fine but some JsonArray elements come as zeros even though they are numbers in the A
For Anyone who is doing it in Kotlin, you can get it this way,
val gsonHandler = Gson() val element: JsonElement = gsonHandler.toJsonTree(yourListOfObjects, object : TypeToken>() {}.type)