This library is an O(n) json parser that creates the least amount of objects. It works fast and does not trigger the garbage collector, making it suitable for old android devices.
This library is 10 times faster than org.json in parsing 25 Megabytes of json text:
library | time (ms) |
---|---|
reyminsoft.json | 046 |
json.org: | 530 |
The parser has an O(n) time complexity, meaning it iterates over the json string only once and does all the processing.
It also avoids creating unnecessary objects that trigger the garbage collector.
- The library assumes that the json input has valid syntax. this assumption allows for optimizations like seeing the character
f
and interpreting it asfalse
, without looping through the remaining characters.
in case of an invalid json input, the thrown exception may not have a descriptive and in detail explanation. - currently the api for manipulating json objects or arrays is quite basic. (get and put only)
- The parser passes all the unit tests, including the processing of 25 Mbs of json text. But the code has not been used in the wild.
- The parser converts tiny double values with a tiny error. it uses specialized algorithm to convert numbers without creating new objects or implicitly iterating over the characters, and this comes at the cost of a very small error on very small numbers.
Developed by Amin Sarabi .