flutter_toon 0.0.1 copy "flutter_toon: ^0.0.1" to clipboard
flutter_toon: ^0.0.1 copied to clipboard

A Flutter package for converting JSON to TOON and TOON to JSON.

flutter_toon #

A small Flutter package for converting JSON ↔ TOON.

TOON is a compact, human-readable format for structured data. This package keeps the API simple and covers the common TOON shapes:

  • flat objects
  • nested objects
  • primitive arrays
  • uniform arrays of objects

Features #

  • Convert a JSON string or decoded JSON value to TOON
  • Convert TOON back to a compact JSON string
  • Keep output readable and easy to debug

Usage #

import 'package:flutter_toon/flutter_toon.dart';

final toon = jsonToToon({
	'user': {
		'id': 1,
		'name': 'Ada',
	}
});

final json = toonToJson('user:\n  id: 1\n  name: Ada');

Example #

Here is a small JSON API error response example:

final toon = jsonToToon({
	'jsonapi': {'version': '1.1'},
	'errors': [
		{
			'code': '123',
			'source': {'pointer': '/data/attributes/firstName'},
			'title': 'Value is too short',
			'detail': 'First name must contain at least two characters.',
		},
	],
});

final json = toonToJson(toon);

This becomes TOON like this:

jsonapi:
	version: "1.1"
errors[1]:
	- code: "123"
		source.pointer: /data/attributes/firstName
		title: Value is too short
		detail: First name must contain at least two characters.

Notes #

  • The package is designed for common TOON structures used in LLM prompts.
  • Uniform object arrays are encoded in table form.
  • Complex mixed arrays are not supported in this first version.
0
likes
160
points
44
downloads

Documentation

API reference

Publisher

verified publisherdinethsiriwardana.me

Weekly Downloads

A Flutter package for converting JSON to TOON and TOON to JSON.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_toon