https://kotlinlang.org logo
Title
k

karelpeeters

08/02/2018, 9:07 PM
Is there a way to parse a JsonObject as part of parsing with the object mapper? Something like this:
data class Foo(val a: JsonObject)

fun main(args: Array<String>) {
	val json = """{ "a": { "hello": "world" } }"""

	val result = Klaxon().parse<Foo>(json)
	println(result)
}
s

Shawn

08/02/2018, 9:10 PM
are you looking for
Klaxon.parseJsonObject(String)
, or am I misunderstanding you
Ohh, I see what you mean, my bad - I actually tried doing something like this not too long ago and also couldn’t get the
JsonObject
members to work intuitively
k

karelpeeters

08/02/2018, 9:15 PM
It's probably possible to register a custom parser for
JsonObject
that just returns the json itself, I'll look into that.