Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON.parse to Map howto (new syntax 0.3.1_r17328)

Tags:

dart

What's the new syntax for the following please? :

Map mAcctData = JSON.parse(sResponse);    // sResponse is Json String
like image 235
Brian Oh Avatar asked Dec 11 '25 14:12

Brian Oh


1 Answers

parse (and stringify) has been moved to a top-level function.

import 'dart:json' as JSON;  // note the JSON name

main() {
  var text = // some text...
  var map = JSON.parse(text); // using the JSON name
}

or

import 'dart:json'; // note, no JSON name

main() {
  var text = // some text...
  var map = parse(text); // calling parse as a top-level function.
}
like image 134
Chris Buckett Avatar answered Dec 14 '25 04:12

Chris Buckett



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!