dart_json 1.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 66

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.1

  • Dart 2.0 support added
  • example/main.dart added
  • Pub issues and suggestions resolved

1.0.0

  • Initial release

example/main.dart

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}
}

Use this package as a library

1. Depend on it

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


dependencies:
  dart_json: ^1.0.1

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]
31
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]
66
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: web, other

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test 1.3.0