question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Json parsing using Object binding is extremely slow, unless parsed into a JsonObject first.

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
fabiosussettocommented, Jun 19, 2020

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!

1reaction
TitanKingcommented, Nov 5, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fastest way to parse JSON from String when format is known
The usual libraries, Gson and Jackson , are way too slow for my needs (> 100us for each String to Json parse, according...
Read more >
How to Parse JSON in Java Object using Jackson - Java67
The key object here is ObjectMapper class from the Jackson library, which is used for converting JSON to Java and vice-versa.
Read more >
Parsing JSON with PowerShell - Microsoft Community Hub
Q: I try to parse my JSON with the handy dandy “ConvertFrom-JSON” cmdlet but it only works in PowerShell 7, not in my...
Read more >
Using JSON.NET for dynamic JSON parsing - Rick Strahl
Rather the JSON.NET objects are the containers that receive the data as I build up my JSON structure dynamically, simply by adding properties....
Read more >
PHP-Style JSON Parsing in Java with Jsoniter - SitePoint
Parse the JSON as Map<String, Object> and read values from it. · Define a class and use data binding. · Some JSON parser...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found