pdata
A dependency-free reader/writer for JSON, YAML, and TOML config files, written in pure Dart.
One function call reads a .json, .yaml, or .toml file into plain Dart objects — format is guessed from the extension, and penv’s neighbor for typed config, typed accessors, works the same way.
import 'package:pdata/pdata.dart';
void main() {
final config = pdataReadFile('config.yaml') as Map<String, dynamic>;
print(config.getString('name'));
pdataWriteFile('config.json', config);
}
Getting Started
Install the package and read your first config file.
Examples
Five runnable programs covering every format, typed access, errors, and async I/O.
API Reference
pdataReadFile, pdataWriteFile, the format-specific codecs, and the typed accessors.
FAQ
Common questions about format guessing, TOML’s no-null rule, and more.
Why pdata
- No dependencies — JSON goes through
dart:convert(part of the SDK); YAML and TOML are parsed and written by pdata’s own single-file parsers. - One API across three formats —
pdataReadFile/pdataWriteFileguess the format from the file extension, so switching a config file from YAML to TOML is a rename, not a rewrite. - Typed accessors —
getInt,getDouble,getBool,getString,getList,getMapon theMap<String, dynamic>pdata returns, with clearFormatExceptions instead of null-check crashes. - Sync and async — every file-based function has an
Asynccounterpart for code that avoids blocking I/O. - Covers real-world config syntax — block and flow YAML, literal/folded block scalars, TOML tables and arrays-of-tables, dotted keys, and more. See Supported Formats for the exact subset.
Install
dart pub add pdata
- Package: pdata on pub.dev
- Repository: psdkjoon/pdata
- License: MIT
- Requires: Dart SDK
^3.5.0