dart_json5parse 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 54

dart_json5parse

Not strictly tested, there may be many problems 🐞🐞🐞

example #

import 'dart:io';

import 'package:dart_json5parse/dart_json5parse.dart';

String __filename = Platform.script.path.replaceFirst('/', '');
String __dirname = Directory(__filename).parent.path;
void main() async {
  var f = File(__dirname + '/test.json5');
  var r = json5Parse(await f.readAsString());
  print(r['unquoted']);
  print(r['singleQuotes']);
  print(r['lineBreaks']);
  print(r['hexadecimal']);
  print(r['leadingDecimalPoint']);
  print(r['andTrailing']);
  print(r['positiveSign']);
  print(r['andIn']);
  print(r['andIn'][0]);
}

test.json5:

{
  // comments
  unquoted: "and you can quote me on that",
  singleQuotes: 'I can use "double quotes" here',
  lineBreaks: "Look, Mom! \
No \\n's!",
  hexadecimal: 0xdecaf,
  leadingDecimalPoint: 0.8675309,
  andTrailing: 8675309,
  positiveSign: +1,
  andIn: ["arrays"]
}

run:

λ dart ./example/dart_json5parse_example.dart
and you can quote me on that
'I can use "double quotes" here'
Look, Mom! \No \
's!
912559
0.8675309
8675309
1
[arrays]
arrays

0.1.0 #

  • Initial version, created by Stagehand

example/dart_json5parse_example.dart

import 'dart:io';

import 'package:dart_json5parse/dart_json5parse.dart';

String __filename = Platform.script.path.replaceFirst('/', '');
String __dirname = Directory(__filename).parent.path;
void main() async {
  var f = File(__dirname + '/test.json5');
  var r = json5Parse(await f.readAsString());
  print(r['unquoted']);
  print(r['singleQuotes']);
  print(r['lineBreaks']);
  print(r['hexadecimal']);
  print(r['leadingDecimalPoint']);
  print(r['andTrailing']);
  print(r['positiveSign']);
  print(r['andIn']);
  print(r['andIn'][0]);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_json5parse: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_json5parse/dart_json5parse.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
16
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Health issues and suggestions

Document public APIs. (-1 points)

2 out of 2 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
pedantic ^1.8.0
test ^1.6.0