Home

Awesome

THIS REPOSITORY IS NO LONGER MAINTAINED.

ModelMapper

ModelMapper is an Android library to help parsing JSON strings and mapping it to objects of model classes automatically.

This is your json.

{
  "name": "Eunjae Lee",
  "noshow": false,
  "albuminfo": {
    "count": 10
  }
}

This is your model.

class User {
  
  String name;
  
  @JsonProperty("noshow")
  boolean noShow;
  
  @JsonProperty("albuminfo.count")
  int albumCount;
}

And all you need to do is:

User user = ModelMapper.getInstance().generate(User.class, jsonString);

And if you're using AndroidAnnotations, it gets simpler. You just need to put an converter at rest client interface.

@Rest(converters = {JsonToModelConverter.class})
public interface MyRestClient {
 
  @Get("/...")
  User getUser();
}

It's done.

Download

Maven

  <dependency>
    <groupId>net.eunjae.android.modelmapper</groupId>
    <artifactId>ModelMapper</artifactId>
    <version>1.0.6</version>
  </dependency>

Gradle

  compile 'net.eunjae.android.modelmapper:ModelMapper:1.0.6'

Usage Documentation

Check out the wiki page: https://github.com/eunjae-lee/ModelMapper/wiki

License

MIT

Changelog

1.0.6 (2014/03/12)

1.0.5 (2014/03/06)

1.0.4

1.0.3

1.0.2

Bitdeli Badge