json_util 0.5.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

json_util Build Coverage #

Type-safe JSON-encoding and JSON-decoding utilities for Dart.

Usage #

A simple usage example:

import 'package:json_util/json_util.dart';

void main() {
  const myJson = '{"hello":"world"}';
  final decodedValue = DecodedValue.from(myJson);
  final map = decodedValue.asMap();
  final encodableValue = EncodableValue.map(map);
  final yourJson = encodableValue.encode();
  print(myJson == yourJson); // true
}

Available components: #

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0.5.1 #

  • Documentation enhancement.

0.5.0 #

  • JsonUtilError removed.
  • DecodedValue: toString() added.
  • Convert methods exposed.

0.4.0 #

  • DecodedValueError and EncodableValueError exposed.

0.3.0 #

  • optional parameters added to asObject() and asObjectList()

0.2.0 #

  • JsonUtilError exposed.

0.1.0 #

  • First stable release.

0.0.1 #

  • Initial version (EncodableValue and DecodedValue added).

example/json_util_example.dart

import 'package:json_util/json_util.dart';

void main() {
  const myJson = '{"hello":"world"}';
  final decodedValue = DecodedValue.from(myJson);
  final map = decodedValue.asMap();
  final encodableValue = EncodableValue.map(map);
  final yourJson = encodableValue.encode();
  print(myJson == yourJson); // true
}

Use this package as a library

1. Depend on it

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


dependencies:
  json_util: ^0.5.1

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:json_util/json_util.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
63
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

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

  • Dart: 2.8.1
  • pana: 0.13.8-dev

Health suggestions

Fix lib/src/errors.dart. (-0.50 points)

Analysis of lib/src/errors.dart reported 1 hint:

line 95 col 32: 'CastError' is deprecated and shouldn't be used. Use TypeError instead.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
benchmark_harness ^1.0.5
pedantic ^1.8.0
test ^1.9.3
test_coverage ^0.4.0