dart_json 1.0.0

  • README.md
  • Installing
  • Versions
  • 61

GitHub license Travis Pub Coverage Status

DartJson #

DartJson is a JSON to object mapper.

  • It's fast
  • dependency-less
  • works with nested objects
  • property names in classes can be different to the name in the json

📦 Installation #

Add the following to your pubspec.yaml:

  dart_json: ^1.0.0

Then run pub get

💡 Usage #

Importing #

import 'package:dart_json/dart_json.dart';

Using it #

import 'package:dart_json/dart_json.dart';

class Person {
  String firstName;

  String lastName;

  int age;

void main() {
  var json = '{"first_name": "Max", "lastName": "Mustermann", "age": 25}';
  Person p = Json.deserialize<Person>(json);
  print(p.firstName); // Max
  print(p.lastName); // Mustermann
  print(p.age); // 25

  var newJson = Json.serialize(p);
  print(newJson); // {"first_name":"Max","lastName":"Mustermann","age":25}

🔬 Testing #

$ pub run test

🤝 Contribute #

Feel free to fork and add pull-requests 🤓

1.0.0 #

  • Initial release

Use this package as a library

1. Depend on it

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

  dart_json: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support 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_json/dart_json.dart';
Version Uploaded Documentation Archive
1.0.1 Sep 29, 2018 Go to the documentation of dart_json 1.0.1 Download dart_json 1.0.1 archive
1.0.0 Sep 29, 2018 Go to the documentation of dart_json 1.0.0 Download dart_json 1.0.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.3.1
  • pana: 0.12.17


Detected platforms: web, other

Primary library: package:dart_json/dart_json.dart with components: mirrors.

Health suggestions

Fix lib/json.dart. (-1.99 points)

Analysis of lib/json.dart reported 4 hints:

line 20 col 13: Don't explicitly initialize variables to null.

line 69 col 13: Don't explicitly initialize variables to null.

line 136 col 16: Use isNotEmpty instead of length

line 137 col 13: Use isNotEmpty instead of length

Fix lib/annotation/json_property.dart. (-0.50 points)

Analysis of lib/annotation/json_property.dart reported 1 hint:

line 15 col 23: Don't type annotate initializing formals.

Fix lib/dart_json.dart. (-0.50 points)

Analysis of lib/dart_json.dart reported 1 hint:

line 10 col 9: Name libraries using lowercase_with_underscores.

Maintenance suggestions

The package description is too short. (-15 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.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dart_json.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0-dev.0.0 <3.0.0
Dev dependencies
test 1.3.0