json_mapper 0.2.0

  • README.md
  • Installing
  • Versions
  • 21


A Simple lightweight JSON mapping utility.

How do I use it?

Download the dependency through Dart Pub Package manager. Add the following line to your pubspec.yaml dependencies:

json_mapper: "any"

Once you're done, get the package using pub get, then import it:

import 'package:json_mapper/json_mapper.dart' as jmap;

To serialize an object:

Use the serialize(Object obj) function. It takes any Dart object.

import 'package:json_mapper/json_mapper.dart' as jmap;

class Contact {
  int name;
  int mobile;
  int email;

void main() {
  Contact bob = new Contact()
    ..name = 'Bob Smith'
    ..mobile = '4161234567'
    ..email = 'bob.smith@example.com'
  String json = jmap.serialize(bob);

The output should be similar to:

Use the deserialize(String json, Type type) function. It takes a string, and any Dart Type, even your own.

{"name":"Bob Smith","mobile":"4161234567","email":"bob.smith@example.com"}

To deserialize a string back to an object


void main() {
  String json = '{"name":"Bob Smith","mobile":"4161234567","email":"bob.smith@example.com"}';
  Contact bobFromJson = jmap.deserialize(json, Contact);

1. Depend on it

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

  json_mapper: "^0.2.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:json_mapper/json_mapper.dart';
Version Uploaded Documentation Archive
0.2.0 Nov 26, 2014 Go to the documentation of json_mapper 0.2.0 Download json_mapper 0.2.0 archive
0.1.0 Nov 15, 2014 Go to the documentation of json_mapper 0.1.0 Download json_mapper 0.1.0 archive


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

  • Dart: 2.0.0-dev.31.0
  • pana: 0.10.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
70 / 100
Reflects how tidy and up-to-date the package is. [more]
0 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: web, other

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


  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Fix issues reported by dartanalyzer or dartfmt.

    dartanalyzer or dartfmt reported 2 errors 3 hints.

    Strong-mode analysis of lib/json_mapper.dart failed with the following error:

    line: 139 col: 70
    The argument type 'MethodMirror' can't be assigned to the parameter type 'VariableMirror'.

    Run dartfmt to format lib/metadata.dart.

    Similar analysis of the following files failed:

    • lib/test.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use json_mapper.dart.


Package Constraint Resolved Available
Direct dependencies
unittest >=0.11.0 <0.12.0 0.11.7 0.12.4+1
Transitive dependencies
path 1.5.1
stack_trace 1.9.2