Skip to content

How does this compare with ArduinoJson? #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bblanchon opened this issue Nov 16, 2019 · 2 comments
Closed

How does this compare with ArduinoJson? #4

bblanchon opened this issue Nov 16, 2019 · 2 comments
Labels
type: support OT: Request for help using the project

Comments

@bblanchon
Copy link

Hi!

I'm the developer of ArduinoJson.
I'm curious to know how this library differs from it.
Why should someone choose this one over ArduinoJson?

Best Regards,
Benoit

@sandeepmistry sandeepmistry added the type: support OT: Request for help using the project label Nov 18, 2019
@sandeepmistry
Copy link
Contributor

Hi @bblanchon,

The goal of this library is to be simple to use, and avoid C/C++ concepts that Arduino users are not familiar with.

@bblanchon
Copy link
Author

Hi @sandeepmistry,

Thank you for your answer but it doesn't provide any comparison with ArduinoJson, nor any guidance to choose one or the other.

I made my own comparison and benchmark; you can read the article on arduinojson.org
Here is a summary of the article:

Features

JSON support

ArduinoJson Arduino_JSON
JSON serialization ✔️ ✔️
JSON deserialization ✔️ ✔️
Decode UTF-16 literals ✔️ ✔️
Comments in JSON input ✔️
Single quotes in JSON input ✔️
Prettified output ✔️
Deserialization error information ✔️

Compatible types

ArduinoJson Arduino_JSON
Arduino String ✔️ ✔️
Flash strings ✔️ ✔️
Arduino streams ✔️
STL string ✔️
STL streams ✔️
long long ✔️

Integration with the C++ language

ArduinoJson Arduino_JSON
Access values with [] ✔️ ✔️
Implicit casts ✔️ ✔️
Namespace ✔️
const friendly ✔️
for friendly ✔️
template friendly ✔️
Deserialization error information ✔️
Usable outside of Arduino ✔️

Other features

ArduinoJson Arduino_JSON
Thread-safe ✔️ ✔️
MessagePack serialization ✔️
MessagePack deserialization ✔️
Stack-only allocation ✔️
Fixed heap allocation ✔️
Zero-copy ✔️

Project information

ArduinoJson Arduino_JSON
License MIT LGPL
Test coverage 98% 0%
Popularity 4055 21
Documentation ✔️

Performance

Serialize to Serial

ArduinoJson Arduino_JSON
Program size 3.6 KB ✔️ 7.9 KB
Running time 2.2 ms ✔️ 2.3 ms
Heap allocations 0 ✔️ 20
RAM usage 426 B ✔️ 454 B
Fragmentation 0 % ✔️ 1.5 %

Serialize to String

ArduinoJson Arduino_JSON
Program size 5.2 KB ✔️ 8.0 KB
Running time 2.1 ms 1.9 ms ✔️
Heap allocations 2 ✔️ 21
RAM usage 499 B ✔️ 534 B
Fragmentation 0 % ✔️ 6.21 %

Serialize to char[]

ArduinoJson Arduino_JSON
Program size 3.8 KB ✔️ 8.2 KB
Running time 1.7 ms ✔️ 1.9 ms
Heap allocations 0 ✔️ 21
RAM usage 492 B ✔️ 522 B
Fragmentation 0 % 0 %

Deserialize from const char*

ArduinoJson Arduino_JSON
Program size 4.0 KB ✔️ 11 KB
Running time 0.8 ms ✔️ 0.9 ms
Heap allocations 0 ✔️ 10
RAM usage 449 B ✔️ 540 B
Fragmentation 0 % 0%

Deserialize from char[]

ArduinoJson Arduino_JSON
Program size 4.1 KB ✔️ 11 KB
Running time 0.8 ms ✔️ 0.9 ms
Heap allocations 0 ✔️ 10
RAM usage 488 B ✔️ 540 B
Fragmentation 0 % 0%

Using a char[] enables the zero-copy mode of ArduinoJson, saving a large amount of memory.

Deserialize from Serial

ArduinoJson Arduino_JSON
Program size 4.2 KB ✔️ 11.3 KB
Running time 2.9 ms ✔️ 1004 ms
Heap allocations 0 ✔️ 73
RAM usage 387 B ✔️ 468 B
Fragmentation 0 % ✔️ 3.82 %

Conclusion

  • ArduinoJson has many more features than Arduino_JSON.
  • ArduinoJson is almost twice smaller than Arduino_JSON.
  • ArduinoJson is slightly faster than Arduino_JSON.
  • ArduinoJson consumes less RAM than Arduino_JSON (provided that the memory pool is adjusted).
  • ArduinoJson doesn't increase memory fragmentation.
  • Arduino_JSON is slightly easier to use

Best Regards,
Benoit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: support OT: Request for help using the project
Projects
None yet
Development

No branches or pull requests

2 participants