json_object_mapper 1.0.0

  • Readme
  • Changelog
  • Installing
  • 73

json_object_mapper #

A simple and easy way to map Objects to/from Map and JSON with Web support.

Main features:

  • Compatible with Web (dart2js) and VM.

  • No code generation.

  • Uses Mirrors only if available in platform (transparent load).

Usage #

A simple usage example:

import 'package:json_object_mapper/json_object_mapper.dart';

class User extends JSONObject {
  String username ;
  String email ;

  User.fields(this.username, this.email);

  User.json(String json) {
    initializeFromJSON(json) ;

  List<String> getObjectFields() {
    return getObjectFieldsDefault() ;
    //return ['username' , 'email'] ;

  String toString() {
    return 'User{username: $username, email: $email}' ;


main() {
      User user1 = User.fields("joe", "joe@mail.com") ;
      print("User[1]: $user1");      
      // User[1]: User{username: joe, email: joe@mail.com}

      // {"username":"joe","email":"joe@mail.com"}

      User user2 = User.json( '{"username":"joe2","email":"joe2@mail.com"}' ) ;
      print("User[2]: $user2");
      // User[2]: User{username: joe2, email: joe2@mail.com}
      // {"username":"joe2","email":"joe2@mail.com"}


Features and bugs #

Please file feature requests and bugs at the issue tracker.

Author #

Graciliano M. Passos: gmpassos@GitHub.

License #

Dart free & open-source license.

1.0.0 #

  • Initial version, created by Stagehand

Use this package as a library

1. Depend on it

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

  json_object_mapper: ^1.0.0

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_object_mapper/json_object_mapper.dart';
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 29, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev

Health suggestions

Format lib/json_object_mapper.dart.

Run dartfmt to format lib/json_object_mapper.dart.

Format lib/src/json_object.dart.

Run dartfmt to format lib/src/json_object.dart.

Format lib/src/json_object_base.dart.

Run dartfmt to format lib/src/json_object_base.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/json_object_generic.dart (Run dartfmt to format lib/src/json_object_generic.dart.)
  • lib/src/json_object_html.dart (Run dartfmt to format lib/src/json_object_html.dart.)
  • lib/src/json_object_mirror.dart (Run dartfmt to format lib/src/json_object_mirror.dart.)

Maintenance suggestions

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 json_object_mapper.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.6.0 <3.0.0
Dev dependencies
pedantic ^1.8.0
test ^1.6.0