son

build coverage pub package License: MIT

A binary encoding format for JSON data that supports a focused subset of Dart types.

✨ Features

🤏 Smaller footprint than normal JSON encoded data.

📖 Built-in dictionary support for strings (optional).

🔟 Support for typed data lists like Float32List, Uint8List and others.

🤖 Automatically encodes Dart classes that have a toJson or toMap method.

🧑‍💻 Example

import 'dart:typed_data';

import 'package:son/son.dart';

class Funky {
  Map<String, dynamic> toMap() => {'funky': 'stuff'};
}

void main() async {
  final encoded = son.encode({
    'hello': 'world',
    'bytes': Uint8List.fromList([1, 2, 3]),
    'funky': Funky(),
  });
  print('Bytes: $encoded');

  final decoded = son.decode(encoded)! as Map;
  print(decoded['hello'] == 'world'); // true
  print(decoded['bytes'] is Uint8List); // true
  print(decoded['funky'] is Funky); // false, it is a map.
}

Libraries

son