tame_yaml 0.1.0 copy "tame_yaml: ^0.1.0" to clipboard
tame_yaml: ^0.1.0 copied to clipboard

Decodes a strict, unambiguous subset of YAML 1.2 into immutable values of built-in Dart types.

example/tame_yaml_example.dart

import 'package:tame_yaml/tame_yaml.dart';

void main() {
  final pubspec = yamlDecode('''
name: tame_yaml
version: 0.1.0
environment:
  sdk: ^3.12.0
topics:
  - yaml
  - parsing
''');

  switch (pubspec) {
    case {
      'name': final String name,
      'version': final String version,
      'environment': {'sdk': final String sdkConstraint},
      'topics': [final String firstTopic, ...],
    }:
      print('$name $version ($firstTopic) needs Dart $sdkConstraint');
    default:
      throw const FormatException('Invalid pubspec shape.');
  }

  final manifests = yamlDecodeAll('''
---
name: tame_yaml
---
name: tame_yaml_benchmarks
''');
  print('Decoded ${manifests.length} workspace manifests.');

  try {
    final _ = yamlDecode('dependencies:\n  meta: ^1.0.0\n  meta: ^1.16.0');
  } on YamlException catch (error) {
    print('${error.code}: ${error.message}');
  }
}
1
likes
160
points
7
downloads

Documentation

API reference

Publisher

verified publisherdartcommunity.dev

Weekly Downloads

Decodes a strict, unambiguous subset of YAML 1.2 into immutable values of built-in Dart types.

Repository (GitHub)
View/report issues

Topics

#config #yaml

License

MIT (license)

Dependencies

meta

More

Packages that depend on tame_yaml