Json parsing using Object binding is extremely slow, unless parsed into a JsonObject first.
See original GitHub issueThe 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:
- Created 5 years ago
- Reactions:8
- Comments:23 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.