JSONAPI Implementation for Android



Download Build Status

Morpheus is a JSONAPI deserializer for android that uses java reflection. You can define your own java classes to deserialize.

Take a look at the documentation.


 compile 'com.xamoom.android:morpheus:0.4.3'


Prepare your resources

  1. extend Resource
  2. Use @SerializedName() annotation when your field name differs from the json.
  3. Create relationship mapping with the @Relationship() annotation.
public class Article extends Resource {
  private String title;
  private Author author;
  private List<Comment> comments;

Deserialize your data

  1. Create a Morpheus instance
  2. Register your resources
  3. parse your JSON string
Morpheus morpheus = new Morpheus();
//register your resources
Deserializer.registerResourceClass("articles", Article.class);
Deserializer.registerResourceClass("people", Author.class);
Deserializer.registerResourceClass("comments", Comment.class);
JsonApiObject jsonApiObject =

Article article = (Article)jsonApiObject.getResources().get(0);
Log.v(TAG, "Article Id: " + article.getId())

Development status

Morpheus can:

  • deserialize data object or array
  • deserialize relationships
  • map includes to relationships
  • deserialize links, meta, errors

Data Attribute Mapping

At the moment Morpheus maps

  • Strings -> String
  • Floats -> double
  • Booleans -> boolean
  • JSONArrays -> List<Object> (with Gson)
  • JSONObject -> HashMap<String, Object> (with Gson)

You can write your own AttributeMapper by extending AttributeMapper.java and initialize Morpheus with your mapper.


If you want to contribute: make your changes and do a pull request.