Built in Type Adapters

suggest change

Moshi has built-in support for reading and writing Java's core data types:

It writes your model classes field by field. For the JSON below, Moshi uses these classes:

class BlackjackHand {
  public final Card hidden_card;
  public final List<Card> visible_cards;
  // ...
}

class Card {
  public final char rank;
  public final Suit suit;
  // ...
}

enum Suit {
  CLUBS, DIAMONDS, HEARTS, SPADES;
}
{
  "hidden_card": {
    "rank": "6",
    "suit": "SPADES"
  },
  "visible_cards": [
    {
      "rank": "4",
      "suit": "CLUBS"
    },
    {
      "rank": "A",
      "suit": "HEARTS"
    }
  ]
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents