Test case
1 generated file · +1 −1test/inputs/json/priority/issue2680-scalar-array.json
Mkotlindefault / TopLevel.kt+1 −1
| @@ -12,6 +12,6 @@ class TopLevel(elements: Collection<Long>) : ArrayList<Long>(elements) { | ||
| 12 | 12 | public fun toJson() = klaxon.toJsonString(this) |
| 13 | 13 | |
| 14 | 14 | companion object { |
| 15 | - public fun fromJson(json: String) = TopLevel(klaxon.parseArray<Long>(json)!!) | |
| 15 | + public fun fromJson(json: String) = TopLevel(klaxon.parseArray<Any>(json)!!.map { when (it) { is Int -> it.toLong(); is Long -> it; else -> throw IllegalArgumentException() } }) | |
| 16 | 16 | } |
| 17 | 17 | } |
Test case
1 generated file · +17 −0test/inputs/schema/issue2680-top-level-array.schema
Aschema-kotlindefault / TopLevel.kt+17 −0
| @@ -0,0 +1,17 @@ | ||
| 1 | +// To parse the JSON, install Klaxon and do: | |
| 2 | +// | |
| 3 | +// val topLevel = TopLevel.fromJson(jsonString) | |
| 4 | + | |
| 5 | +package quicktype | |
| 6 | + | |
| 7 | +import com.beust.klaxon.* | |
| 8 | + | |
| 9 | +private val klaxon = Klaxon() | |
| 10 | + | |
| 11 | +class TopLevel(elements: Collection<Long>) : ArrayList<Long>(elements) { | |
| 12 | + public fun toJson() = klaxon.toJsonString(this) | |
| 13 | + | |
| 14 | + companion object { | |
| 15 | + public fun fromJson(json: String) = TopLevel(klaxon.parseArray<Any>(json)!!.map { when (it) { is Int -> it.toLong(); is Long -> it; else -> throw IllegalArgumentException() } }) | |
| 16 | + } | |
| 17 | +} |
No generated files match these filters.