Logo

Programming-Idioms

History of Idiom 91 > diff from v21 to v22

Edit summary for version 22 by ChrisR:
[Dart] the case was wrong for Dart2 and typing is stringer

Version 21

2018-09-04, 19:00:17

Version 22

2018-09-11, 22:48:17

Idiom #91 Load JSON file into struct

Read from file data.json and write its content into object x.
Assume the JSON data is suitable for the type of x.

Idiom #91 Load JSON file into struct

Read from file data.json and write its content into object x.
Assume the JSON data is suitable for the type of x.

Imports
import 'dart:io' show File;
import 'dart:convert' show JSON;
Imports
import 'dart:io' show File;
import 'dart:convert' show json;
Code
var x = JSON.decode(await new File('data.json').readAsString());
Code
Map x = json.jsonDecode(await new File('data.json').readAsString());
Comments bubble
x is a Map
Comments bubble
x is a Map