'kotlinx decodeFromString to 'ArrayList' vs 'CustomClass extending ArrayList'
Why does this work:
val string = "[1, 2, 3]"
val result: ArrayList<Int> = json.decodeFromString(string)
but this doesn't:
@Serializable
class MyClass : ArrayList<Int>()
val string = "[1, 2, 3]"
val myClass: MyClass = json.decodeFromString("string")
throws this error:
Expected start of the object '{', but had 'EOF' instead
MyClass is also an ArrayList so I'm unsure why it doesn't work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
