简体   繁体   中英

FasterXML Jackson Smile vs json

I was going through some online resources and found that jackson can be used for serialization and deserialization for java objects and json string respectively. But at the same time i found something called smile . So below are my doubts:

  1. is jackson json library serializes to text based byte stream for json representation
  2. is smile serializes to non text ie binary byte stream for same binary representation
  3. if the above assumptions are correct then the byte available from jackson json library can be deserialized by other libraries which understand json (like some python, ruby json serialization/deserialization library). But same is not possible for smile as it may have a very specific binary representation of a java object. Am I correct?

If i am incorrect please guide me to the answer. Thanks.

As i am very new to computer science field, my apology if this question does fits into stack overflow standard.

The major difference between normal JSON markup and Smile is that Smile is a binary markup version of JSON. Since smile is more compact, it has less overhead when deserializing and is a better option for large and complex payloads.

When to use each markup:

  • JSON/XML - when you want to ensure compatibility of an API, while decoupling it from various serialization protocols. There are variations of each, with embedded metadata, to provide more context for the data.
  • BSON/Smile/Kryo - When you need speed. This can be a real-time application, data collection, internal server communication.

The two formats are compatible: you can send Smile and decode as JSON, by wrapping the proper decoder.

Some benchmark values for each

Just for clarity. My performance testing shown that modern Jackson with Afterburner has semi equal speed with JSON and Smile. Bson4Jackson is 5 times slower.

jacksonMapper_Json__Stream      thrpt    5   950,796 ±  60,451  ops/ms
jacksonMapper_Json__Stream_Ab   thrpt    5  1572,641 ±  43,928  ops/ms
jacksonMapper_Smile__Stream     thrpt    5   945,343 ±  25,617  ops/ms
jacksonMapper_Smile__Stream_Ab  thrpt    5  1482,769 ±  27,915  ops/ms
jacksonMapper_Bson__Stream      thrpt    5   329,239 ±  12,119  ops/ms
jacksonMapper_Bson__Stream_Ab   thrpt    5   361,253 ±  30,670  ops/ms

Always test with a data set closest to yours.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM