Klaxon's JSON pretty printing outputs "["result"]"

641 Views Asked by At
val time = json.lookup<String?>("query.results.channel.title").toJsonString(true)

outputs

["Yahoo! Weather - Nome,AK,US"]

is there a way to get the output without the brackets and the quotation marks ?

I guess that

.replace("[\"","").replace("\"]","")

isn't the best way

1

There are 1 best solutions below

0
On BEST ANSWER

The brackets are contained in the default implementation (see https://github.com/cbeust/klaxon/blob/master/src/main/kotlin/com/beust/klaxon/DSL.kt at the very bottom function appendJsonStringImpl)

So it is not possible, to remove them by configuration.

It might work if you write an extension function for this particular class, but i guess this is not what you want.

So this is currently not possible without writing your own extension(-function).