Skip to content

mintware-de/dart-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: ^2.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 🤓

About

A json serializer and deserializer for humans

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published