mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
Correct error for duplicate JSON key for Kotlin. (#789)
Before, the KotlinJsonAdapter threw "java.lang.IndexOutOfBoundsException: Index: 0, Size: 0" on a duplicate key when the key matched a property that was not a constructor parameter.
This commit is contained in:
@@ -17,7 +17,6 @@ package com.squareup.moshi.kotlin.reflect
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonAdapter
|
||||
import com.squareup.moshi.JsonClass
|
||||
import com.squareup.moshi.JsonDataException
|
||||
import com.squareup.moshi.JsonReader
|
||||
import com.squareup.moshi.JsonWriter
|
||||
@@ -77,7 +76,7 @@ internal class KotlinJsonAdapter<T>(
|
||||
|
||||
if (values[index] !== ABSENT_VALUE) {
|
||||
throw JsonDataException(
|
||||
"Multiple values for '${constructor.parameters[index].name}' at ${reader.path}")
|
||||
"Multiple values for '${binding.property.name}' at ${reader.path}")
|
||||
}
|
||||
|
||||
values[index] = binding.adapter.fromJson(reader)
|
||||
|
Reference in New Issue
Block a user