diff --git a/README.md b/README.md index f208131..f849305 100644 --- a/README.md +++ b/README.md @@ -213,6 +213,32 @@ JsonAdapter jsonAdapter = moshi.adapter(Event.class); Event event = jsonAdapter.fromJson(json); ``` +### Parse JSON Arrays + +Say we have a JSON string of this structure: + +```java +[ + { + "rank": "4", + "suit": "CLUBS" + }, + { + "rank": "A", + "suit": "HEARTS" + } +] +``` + +We can now use Moshi to parse the JSON string into a `List`. + +```java +String cardsJsonResponse = ...; +Type type = Types.newParameterizedType(List.class, Card.class); +JsonAdapter> adapter = moshi.adapter(type); +List cards = adapter.fromJson(cardsJsonResponse); +``` + ### Fails Gracefully Automatic databinding almost feels like magic. But unlike the black magic that typically accompanies