Created
May 17, 2012 11:39
-
-
Save iggymacd/2718327 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import('../ThirdParty/dartwatch-JsonObject/JsonObject.dart'); | |
class Stooge extends JsonObject{ | |
Stooge(this.name, this.addresses); | |
List<Address> addresses; | |
String name; | |
} | |
class Address extends JsonObject{ | |
Address(this.city); | |
String city; | |
} | |
class Episode extends JsonObject{ | |
Episode(this.year); | |
String year; | |
} | |
class Example{ | |
static Map getModel(){ | |
List addresses; | |
Map result = new Map(); | |
List stooges = new List(); | |
addresses = [new Address('Sydney'), new Address('Glace Bay')]; | |
stooges.add(new Stooge('Moe', addresses)); | |
addresses = [new Address('Halifax')]; | |
stooges.add(new Stooge('Larry', addresses)); | |
addresses = [new Address('Truro')]; | |
stooges.add(new Stooge('Curly', addresses)); | |
result['stooges'] = stooges; | |
List episodes = new List(); | |
episodes = [new Episode('1967'), new Episode('1955'), new Episode('1949')]; | |
result['episodes'] = episodes; | |
result['contact'] = 'John Doe'; | |
return result; | |
} | |
} | |
void main(){ | |
Map myMap = Example.getModel(); | |
print(myMap); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment