Announcing Klaxon: JSON for Kotlin

https://github.com/cbeust/klaxon

This is a pretty basic library to parse and query JSON in Kotlin. Very basic and the query API can be vastly improved, so feedback welcome.

2 Likes

Looks cool!

I am wondering what's the advantage of this library compare to what Gson already bring?

Well, Gson is a Java library for starters, Klaxon is native Kotlin. Gson doesn't (seem to) have any querying support and since it's Java, it also doesn't support the convenient closure format available in Kotlin. Also, I'm planning to add a Json DSL syntax to create JSON objects for Klaxon, while the Java version is, obviously limited to a bunch of new() and setters.

Gson is also much older than Klaxon so it offers a lot more features too, obviously (e.g. serialization and pretty printing) but I thought it would be more fun to write a library from scracth in Kotlin rather than wrapping an existing Java one.

3 Likes

OK. A DSL to construst adhoc JSON document will indeed be exciting because it can reduce the creation of tiny classes used for JSON objects creation.

1 Like