json_mapper 0.2.0

  • README.md
  • Installing
  • Versions
  • 22

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

Use this package as a library

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

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

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3

Scores

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

Platforms

Detected platforms: web, other

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

Suggestions

  • Maintain CHANGELOG.md.

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

  • Package is too old.

    The package was released more than two years ago.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 2 errors 5 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.

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.6.0
stack_trace 1.9.2