yaml_codec 1.0.0 copy "yaml_codec: ^1.0.0" to clipboard
yaml_codec: ^1.0.0 copied to clipboard

Encoder and decoder for converting YAML object representation.

example/yaml_codec_example.dart

import 'dart:convert' show JsonEncoder, json;

import 'package:yaml_codec/yaml_codec.dart';

void main() {
  var map = {
    'name': 'Joe',
    'ids': [10, 20, 30],
    'desc': 'This is\na multiline\ntext',
    'enabled': true,
  };

  var yamlText = yamlEncode(map);
  print(yamlText);

  var yamlMap = yamlDecode(yamlText);
  print(yamlMap);

  final jsonEncoder = JsonEncoder.withIndent('  ');
  var jsonText = yaml.decoder.fuse(jsonEncoder).convert(yamlText);
  print(jsonText);

  var yamlTextAgain = json.decoder.fuse(yaml.encoder).convert(jsonText);
  print(yamlTextAgain);
}
3
likes
160
points
674
downloads

Publisher

verified publishermichaeldark.dev

Weekly Downloads

Encoder and decoder for converting YAML object representation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

yaml, yaml_writer

More

Packages that depend on yaml_codec