klaxon: Json parsing using Object binding is extremely slow, unless parsed into a JsonObject first.
The library is extremely slow when using object binding. The following code, takes several second to parse the json:
val string = """{"message":"This is a test message!"}"""
val errorMessage = Klaxon().parse<ErrorMessageData>(string)
However, if I first parse the string into a jsonObject and then parse from there, it works really fast:
val string = """{"message":"This is a test message!"}"""
val obj = Klaxon().parseJsonObject(StringReader(string))
val errorMessage = Klaxon().parseFromJsonObject<ErrorMessageData>(obj)
That doesn’t make much sense to me.
Testing was done on a Google Glass 2 (Android Kitkat 4.4) with the latest Kotlin runtime.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 8
- Comments: 23 (10 by maintainers)
Can this caveat be added to the project readme? I was lucky to read this thread, I was going to use this in a production application before reading about this serious issue, which is really a deal breaker. I appreciate it’s not your “fault” (if it can be even consider that), so thanks for your hard work on this!
I do recommend using https://github.com/square/moshi for now. Tested it and works much faster. Kotlinx Serialize is also a way to go. For now, this library is essentially broken.
Done: https://youtrack.jetbrains.com/issue/KT-33760