What is the best way to unmarshall this json in dart:
{
"Ace-spades-2": {
"rank": { "shortName": "A", "longName": "Ace" },
"suit": { "name": "spades" },
"id": "Ace-spades-2"
},
"Two-spades-2": {
"rank": { "shortName": "2", "longName": "Two" },
"suit": { "name": "spades" },
"id": "Two-spades-2"
},
"Three-spades-2": {
"rank": { "shortName": "3", "longName": "Three" },
"suit": { "name": "spades" },
"id": "Three-spades-2"
},
{....a bunch more cards}
}
Here are my classes that I want to unmarshall into. Specifically I want to make the data Map<String,Card>. How can I do this?
class Card {
Rank rank;
Suit suit;
String id;
Card({this.rank,this.suit,this.id})
}
class Rank {
String shortName;
String longName;
Rank({this.shortName, this.longName});
}
class Suit {
String name;
Suit({this.name});
}
In Go, I would just do cards := map[string]Card{} json.Unmarshal(<some_json>, &cards).
What is the best way to do this in dart?