yaml_writer
v2.1.0A library to write YAML documents, supporting Object encoding and 'dart:convert' 'Converter'.
Архив пакета: https://pubdev.letsnova.ru/api/archives/yaml_writer/2.1.0.tar.gz
dart pub add yaml_writerREADME
yaml_writer
A library to write YAML documents, supporting Object encoding and dart:convert Converter.
Usage
A simple usage example:
import 'package:yaml_writer/yaml_writer.dart';
void main() {
final yamlWriter = YamlWriter();
final yamlDoc = yamlWriter.write({
'name': 'Joe',
'ids': [10, 20, 30],
'desc': 'This is\na multiline\ntext',
'enabled': true,
});
print(yamlDoc);
}
OUTPUT:
name: 'Joe'
ids:
- 10
- 20
- 30
desc: |-
This is
a multiline
text
enabled: true
YAML Strings
The writer will try to encode strings using the best format depending on the text,
avoiding to escape " and using | for multiline texts.
Encoding Objects
You can use YAMLWriter.toEncodable to convert an Object to an encodable version,
similar to what is done by dart:convert JsonEncoder.
If YAMLWriter.toEncodable is not set, it will try to call toJson().
Features and bugs
Please file feature requests and bugs at the issue tracker.
Author
Graciliano M. Passos: gmpassos@GitHub.
Liplum: liplum@GitHub
License
Dart free & open-source license.
История изменений
2.1.0
- Refactored string quoting: enhanced the handling of unquoted strings.
- Resolved an issue where empty strings were not supported when using unquoted strings.
- Introduced
YamlWriter.config()as a new constructor, along with theYamlWriterConfigclass.
2.0.1
-
Remove unnecessary trailing spaces from keys with values declared on a new line.
-
test: ^1.25.8
-
coverage: ^1.10.0
2.0.0
- Internals are reworked: now package is relying on a tree-like structure to improve maintainability and scalability.
- Fixed
indentSizevalidation (only values >=1 are allowed). - Resolved https://github.com/gmpassos/yaml_writer/issues/6:
# BEFORE:
field:
-
- 5
- 2
-
a: 3
b: 6
# AFTER:
field:
- - 5
- 2
- a: 3
b: 6
- Update min Dart SDK version constraint from
2.12.0to3.0.0 - Update
lints: ^2.0.1tolints: ^3.0.0
BREAKING CHANGES:
YAMLWriterrenamed toYamlWriter(Effective Dart reference).- Deprecated
identSizeproperty is removed. UseindentSizeinstead. toEncodableproperty is removed. Use constructor parameter instead (YamlWriter#toEncodable).
1.0.3
YAMLWriter:- Added
allowUnquotedStrings. - Rename
identSizetoindentSize. - Deprecate
identSizefield.
- Added
- lints: ^2.0.1
- test: ^1.22.0
- dependency_validator: ^3.2.2
- coverage: ^1.6.1
1.0.2
- Fixed serialization of an empty
Listto[] - Updated GitHub CI.
- lints: ^2.0.0
- test: ^1.17.12
- dependency_validator: ^3.2.0
- coverage: ^1.1.0
1.0.1
- Improve
pubspec.yamldescription. - Improve README.
1.0.0
- Initial version.
