pdata JSON/YAML/TOML for Dart

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);
}

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 formatspdataReadFile/pdataWriteFile guess the format from the file extension, so switching a config file from YAML to TOML is a rename, not a rewrite.
  • Typed accessorsgetInt, getDouble, getBool, getString, getList, getMap on the Map<String, dynamic> pdata returns, with clear FormatExceptions instead of null-check crashes.
  • Sync and async — every file-based function has an Async counterpart 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