JSONAPI Implementation for Android
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.



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


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;


  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())


Morpheus morpheus = new Morpheus();
Deserializer.registerResourceClass("products", Product.class);

JsonApiObject jsonApiObject = new JsonApiObject();

String json = morpheus.createJson(jsonApiObject, false);

Delete an relationship:


JsonApiObject jsonApiObject = new JsonApiObject();

String articleJson = morpheus.createJson(jsonApiObject, false);

Development status

Morpheus can:

  • deserialize data object or array
  • deserialize relationships
  • map includes to relationships
  • deserialize links, meta, errors
  • serialize resources with their relationships and includes

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.