jpl_yaon 1.1.4+11 copy "jpl_yaon: ^1.1.4+11" to clipboard
jpl_yaon: ^1.1.4+11 copied to clipboard

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

🛡️ Fork — Jeff Peiffer Legacy (jpl_) #

Este paquete (jpl_yaon) es un fork de yaon, originalmente creado por Jeff Peiffer y archivado (read-only) junto con toda la org peiffer-innovations.

El prefijo jpl_ significa Jeff Peiffer Legacy: mantenemos vivo el legado de estos paquetes, bumpeados a las últimas versiones de Dart/Flutter, en el monorepo jpl.

Licencia original conservada. El crédito del diseño y la implementación original es de Jeff Peiffer.

I'm done

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
}

Normalization of Results #

As a note, there are some technical differences between JSON and YMAL capabilities. While JSON can only have string based keys, YAML allows for other types. If you would like to prevent the possibility of primitive keys, when parsing set normalize: true and it will guarantee all keys in all returned maps are strings.

0
likes
150
points
1
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

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

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

logging, yaml

More

Packages that depend on jpl_yaon