yaon 1.1.0+1 copy "yaon: ^1.1.0+1" to clipboard
yaon: ^1.1.0+1 copied to clipboard

A simple library to parse either a string from either yaml or json.

Table of Contents

yaon #

A Dart library that can parse a string encoded as either JSON or YAML into a resulting map or array. As a note, for small data sets JSON and YAML can prossess in similar amounts of time but for large data sets, YAML is significantly more expensive, often at a factor of about 10x. So for configuration, YAML can be a great choice but for large objects, JSON will be more performant.

The use of BSON was investigated as another option. However, multiple tests showed that BSON was slower than JSON, even for Dart native compiled applications, and found a suggestion that it's even slower on web.

BSON support may be added in the future should the performance metrics change but for now, there's no meaningful advantage that BSON provides over JSON or YAML.

Using the library #

Add the repo to your Dart pubspec.yaml file.

dependencies:
  yaon: <<version>> 

Then run...

dart pub get

Example #

import 'package:yaon/yaon.dart';

void main() {
  final inputJson = '''
{
  "foo": "bar",
  "list": [
    1, 2, 3, 5, 8
  ],
  "map": {
    "one": 1,
    "two": 2
  },
  "multiline": "First Line\\nSecond Line\\nThird Line"
}
''';

  final inputYaml = '''
foo: bar
list:
  - 1
  - 2
  - 3
  - 5
  - 8
map:
  one: 1
  two: 2
multiline: |-
  First Line
  Second Line
  Third Line

''';
  var result = yaon.parse(inputJson);
  print(result['map']['one']); // 1

  result = yaon.parse(inputYaml);
  print(result['map']['two']); // 2
}
1
likes
0
pub points
80%
popularity

Publisher

verified publisherpeifferinnovations.com

A simple library to parse either a string from either yaml or json.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

logging, yaml

More

Packages that depend on yaon