json_mapper 0.2.0

  • README.md
  • Installing
  • Versions
  • 32

json_mapper

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);
  print(json);
}

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:


dependencies:
  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

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Jan 17, 2018
  • Dart: 2.0.0-dev.15.0
  • pana: 0.9.1

Scores

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

Platforms

Detected platforms: server, web

Multiple platform identified in libraries.

Suggestions

  • Fix lib/json_mapper.dart.

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

  • Maintain CHANGELOG.md.

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

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 1 error(s) and 0 warning(s).

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

Dependencies

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