dart_json 1.0.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 67

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:

dependencies:
  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 {
  @JsonProperty("first_name")
  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:


dependencies:
  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
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
75
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

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

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

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

Format lib/dart_json.dart.

Run dartfmt to format lib/dart_json.dart.

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.

Dependencies

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