Getting all of the variables of a dart class for json encoding -
i have class
class person{ string _fn, _ln; person(this._fn, this._ln); }
is there way list of variables , serialize it? want make tojson, wanted have generic enough such key variable name, , value value of variable name.
in javascript like:
var myobject = {}; //.... whatever want define as.. var tojson = function(){ var list = object.keys(myobject); var json = {}; ( var key in list ){ json[list[key]] = myobject[list[key]] ; } return json.stringify(json); }
dart doesn't have built in functionality serialization. there several packages different strategies available @ pub.dartlang.org. use mirrors, harmful client applications because results in big or huge js output size. new reflectable
packages replaces mirrors
without disadvantage don't know if serialization packages ported use instead. there packages use code generation.
there question answer lists available solutions. i'll when i'm back.
Comments
Post a Comment