Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using js-interop how can I convert javascript Array and Object to native dart Map.

Tags:

dart

dart2js

Is it possible to convert a javascript object or array back to native dart Map and/or List? I'm trying to get a manifest file returned from javascript as Object and want to convert it to a Dart Map object.

like image 750
adam-singer Avatar asked Dec 18 '12 19:12

adam-singer


1 Answers

You can convert a javascript JSON to a Dart JSON with :

import 'dart:json';
import 'package:js/js.dart' as js;

convert(js.Proxy jsonProxy) => JSON.parse(js.context.JSON.stringify(jsonProxy));
like image 113
Alexandre Ardhuin Avatar answered Sep 27 '22 22:09

Alexandre Ardhuin