Smile (data interchange format)

{{Short description|Computer data interchange format based on JSON}}

{{multiple issues|

{{refimprove|date=June 2014}}

{{notability|products|date=March 2014}}

}}

{{Infobox file format

| name = Smile

| mime = application/x-jackson-smile (proposed)

| extension = .sml

| magic = 3a 29 0a ":)\n"

| genre = Data interchange

| extended from = JSON

| standard = no RFC yet

| url = {{URL|https://github.com/FasterXML/smile-format-specification}}

}}

Smile is a computer data interchange format based on JSON. It can also be considered a binary serialization of the generic JSON data model, which means tools that operate on JSON may be used with Smile as well, as long as a proper encoder/decoder exists for the tool.

The name comes from the first 2 bytes of the 4 byte header, which consist of Smiley ":)" followed by a linefeed: a choice made to make it easier to recognize Smile-encoded data files using textual command-line tools.

Efficiency

Compared to JSON, Smile is both more compact and more efficient to process (both to read and write).{{cite web |url=https://github.com/eishay/jvm-serializers/wiki |title=JVM Serializer Benchmark (results) |website=GitHub |accessdate=7 Jun 2014}}

Part of this is due to more efficient binary encoding (similar to BSON, CBOR and UBJSON), but an additional feature is optional use of back references for property names and values.

{{cite web |url=http://wiki.fasterxml.com/SmileFormatSpec#Resolved_Shared_String_references |title=Shared String References in Smile |accessdate=7 Jun 2014}}

Back referencing allows replacing of property names and/or short (64 bytes or less) String values with 1- or 2-byte reference ids.

Implementations

Libraries known to support Smile include:

  • [https://github.com/dakrone/cheshire Cheshire] (Clojure) is a data encoding library that supports Smile as binary alternative to JSON
  • Jackson (Java) with [https://github.com/FasterXML/jackson-dataformats-binary Binary dataformat module] supporting Smile, Avro, CBOR, Ion and Protocol Buffers
  • [https://github.com/pierre/libsmile libsmile] (C/C++; wrappers for Ruby, Perl)
  • [https://github.com/zencoder/go-smile go-smile] for decoding Smile data in Golang
  • [https://github.com/protostuff/protostuff Protostuff] (Java) supports multiple data formats for serialization, including Smile, JSON, XML and Protocol Buffers.
  • [https://github.com/jhosmer/PySmile PySmile] for encoding/decoding Smile data in Python
  • [https://pypi.org/project/newsmile NewSmile] for encoding/decoding Smile data in Python >= 3.7
  • [https://github.com/ngyewch/smile-js smile-js] for decoding Smile data from Javascript
  • [https://crates.io/crates/serde_smile serde_smile] for encoding/decoding data from Rust

Usage

  • Elasticsearch supports Smile with its APIs{{cite web | title=Elasticsearch Guide [8.16] | website=Elastic | date=2024-03-22 | url=https://www.elastic.co/guide/en/elasticsearch/reference/current/api-conventions.html | access-date=2024-11-22}}

See also

References

{{Reflist}}