SMILE Format
Description
SMILE (Smile is a Machine-Interchangeable Language for Everything) is a binary data format similar to JSON but more compact. It was developed by the Jackson JSON library team and provides efficient binary serialization of JSON-like data structures.
File Extensions
.smile- SMILE format files
Implementation Details
Reading
The SMILE implementation:
- Uses
smile-jsonlibrary for decoding - Reads binary SMILE data
- Supports single documents or arrays
- Converts SMILE data to Python objects
Writing
Writing support:
- Encodes Python objects to SMILE format
- Writes binary SMILE data
- Supports nested structures
Key Features
- Binary format: More compact than JSON
- JSON-compatible: Same data structures as JSON
- Nested data: Supports complex nested structures
- Type preservation: Maintains data types
Usage
from iterable import open_iterable
# Basic reading
source = open_iterable('data.smile')
for row in source:
print(row)
source.close()
# Writing
dest = open_iterable('output.smile', mode='w')
dest.write({'name': 'John', 'age': 30})
dest.close()
Parameters
No specific parameters required.
Limitations
- smile-json dependency: Requires
smile-jsonpackage - Binary format: Not human-readable
- Memory usage: Entire file may be loaded into memory
- Less common: Not as widely used as JSON or MessagePack
Compression Support
SMILE files can be compressed with all supported codecs:
- GZip (
.smile.gz) - BZip2 (
.smile.bz2) - LZMA (
.smile.xz) - LZ4 (
.smile.lz4) - ZIP (
.smile.zip) - Brotli (
.smile.br) - ZStandard (
.smile.zst)
Use Cases
- Binary JSON: When JSON is too verbose
- Data storage: Efficient binary storage
- Jackson integration: Working with Jackson-based systems
Related Formats
- JSON - Text-based format
- MessagePack - Similar binary format
- CBOR - Another binary format