A parser for YAML.
Use loadYaml
to load a single document, or loadYamlStream
to load a
stream of documents. For example:
import 'package:yaml/yaml.dart';
main() {
var doc = loadYaml("YAML: YAML Ain't Markup Language");
print(doc['YAML']);
}
This library currently doesn't support dumping to YAML. You should use
JSON.encode
from dart:convert
instead:
import 'dart:convert';
import 'package:yaml/yaml.dart';
main() {
var doc = loadYaml("YAML: YAML Ain't Markup Language");
print(JSON.encode(doc));
}
string_scanner
1.0.0.path
, since we don't actually import it.SourceSpan
s for scalar values surrounded by whitespace.Rewrite the parser for a 10x speed improvement.
Support anchors and aliases (&foo
and *foo
).
Support explicit tags (e.g. !!str
). Note that user-defined tags are still
not fully supported.
%YAML
and %TAG
directives are now parsed, although again user-defined tags
are not fully supported.
YamlScalar
, YamlList
, and YamlMap
now expose the styles in which they
were written (for example plain vs folded, block vs flow).
A yamlWarningCallback
field is exposed. This field can be used to customize
how YAML warnings are displayed.
Fix an import in a test.
Widen the version constraint on the collection
package.
Span
class in documentation and
tests.Switch from source_maps
' Span
class to source_span
's SourceSpan
class.
For consistency with source_span
and string_scanner
, all sourceName
parameters have been renamed to sourceUrl
. They now accept Urls as well as
Strings.
Fix broken type arguments that caused breakage on dart2js.
Fix an analyzer warning in yaml_node_wrapper.dart
.
Add new publicly-accessible constructors for YamlNode
subclasses. These
constructors make it possible to use the same API to access non-YAML data as
YAML data.
Make YamlException
inherit from source_map's [`SpanFormatException`][]. This
improves the error formatting and allows callers access to source range
information.
Backwards incompatibility: The data structures returned by loadYaml
and
loadYamlStream
are now immutable.
Backwards incompatibility: The interface of the YamlMap
class has
changed substantially in numerous ways. External users may no longer construct
their own instances.
Maps and lists returned by loadYaml
and loadYamlStream
now contain
information about their source locations.
A new loadYamlNode
function returns the source location of top-level scalars
as well.
YamlMap
class is deprecated. In a future version, maps returned by
loadYaml
and loadYamlStream
will be Dart HashMap
s with a custom equality
operation.Add this to your package's pubspec.yaml file:
dependencies:
yaml: "^2.1.11"
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter packages get
Alternatively, your editor might support pub get
or packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:yaml/yaml.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
2.1.13 | Sep 27, 2017 |
|
|
2.1.12 | Oct 13, 2016 |
|
|
2.1.11 | Oct 6, 2016 |
|
|
2.1.10 | Jun 23, 2016 |
|
|
2.1.9 | May 4, 2016 |
|
|
2.1.8 | Jan 19, 2016 |
|
|
2.1.7 | Oct 2, 2015 |
|
|
2.1.6 | Sep 28, 2015 |
|
|
2.1.5 | Sep 9, 2015 |
|
|
2.1.4 | Sep 3, 2015 |
|
|
We analyzed this package on Apr 9, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
97 | / 100 |
Health:
Code health derived from static analysis.
[more]
|
99 | / 100 |
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
49 | / 100 |
Overall score:
Weighted score of the above.
[more]
|
88 |
Detected platforms: Flutter, web, other
No platform restriction found in primary library
package:yaml/yaml.dart
.
The description is too short.
Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.
Fix analysis and formatting issues.
Analysis or formatting checks reported 20 hints.
Run
dartfmt
to formatlib/src/equality.dart
.Run
dartfmt
to formatlib/src/event.dart
.Similar analysis of the following files failed:
lib/src/loader.dart
(hint)lib/src/null_span.dart
(hint)lib/src/parser.dart
(hint)lib/src/scanner.dart
(hint)lib/src/style.dart
(hint)lib/src/utils.dart
(hint)lib/src/yaml_document.dart
(hint)lib/src/yaml_exception.dart
(hint)lib/src/yaml_node.dart
(hint)lib/src/yaml_node_wrapper.dart
(hint)lib/yaml.dart
(hint)
Maintain an example.
Create a short demo in the
example/
directory to show how to use this package. Common file name patterns include:main.dart
,example.dart
or you could also useyaml.dart
.
Use analysis_options.yaml
.
Rename old
.analysis_options
file toanalysis_options.yaml
.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.12.0 <2.0.0 | ||
charcode | ^1.1.0 | 1.1.1 | |
collection | >=1.1.0 <2.0.0 | 1.14.9 | |
source_span | >=1.0.0 <2.0.0 | 1.4.0 | |
string_scanner | >=0.1.4 <2.0.0 | 1.0.2 | |
Dev dependencies | |||
path | >=1.2.0 <2.0.0 | 1.5.1 | |
test | >=0.12.0 <0.13.0 |