toon_plus library
TOON Plus - A compact, human-readable data serialization format
TOON is designed to reduce token usage while maintaining readability, making it perfect for LLM applications and API optimization.
Usage
Encoding
import 'package:toon_plus/toon_plus.dart';
final data = {
'name': 'Alice',
'age': 30,
'city': 'New York',
};
final toonString = encode(data);
print(toonString);
// Output:
// name: Alice
// age: 30
// city: New York
Decoding
import 'package:toon_plus/toon_plus.dart';
final toonString = '''
name: Alice
age: 30
city: New York
''';
final data = decode(toonString);
print(data);
// Output: {name: Alice, age: 30, city: New York}
Advanced Options
// Custom indentation
final toonString = encode(data, indent: 4);
// Custom delimiter
final toonString = encode(data, delimiter: '|');
// Decoding with custom indent
final data = decode(toonString, indent: 4);
Classes
- Delimiters
- Available delimiters
Constants
- defaultDelimiter → const String
- Default delimiter