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

What's the new syntax for the next one please?

Map mAcctData = JSON.parse(sResponse);    // sResponse is Json String

      

+3


source to share


1 answer


parse

(and stringify

) 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.
}

      

+6


source







All Articles