Created
June 17, 2019 13:14
-
-
Save PlugFox/2a369ae54afdab0b4464bc4a5e2a1ae6 to your computer and use it in GitHub Desktop.
json example mapping for https://t.me/rudart
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
/* json example mapping for https://t.me/rudart */ | |
import "dart:math"; | |
import "dart:convert"; | |
void main() { | |
String raw = ''' | |
{"rooms": [ | |
{ | |
"id": "49", | |
"name": "Sonata Room 2", | |
"rules": "No rules", | |
"size": 15, | |
"capacity": 12, | |
"cancellationPolicy": 24, | |
"rating": 0, | |
"images": [], | |
"instruments": [ | |
{ | |
"id": "99", | |
"manufacturer": null, | |
"instrumentModel": null, | |
"productionYear": null, | |
"instrument": { | |
"name": "Cello" | |
}, | |
"room": { | |
"id": "49" | |
} | |
} | |
], | |
"schedule": [ | |
{ | |
"id": "802", | |
"roomId": 49, | |
"price": 0, | |
"priceCurrency": "EUR", | |
"priceLoc": 0, | |
"priceLocCurrency": "EUR" | |
} | |
] | |
} | |
]} | |
'''; | |
Map<String, dynamic> data = json.decode(raw); | |
List<Map<String, dynamic>> list = data['rooms'].toList().cast<Map<String, dynamic>>(); | |
print( | |
list.map<int>((room) => room["size"]) | |
.toList() | |
.reduce(max) | |
); // 15 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment