4 ms·
I think the point is that Dart can do that, but he wants to eliminate the step where you perform the cast and just have Dart automagically create meaningful cla
by rmrfrmrf 12y ago
I think the point is that Dart can do that, but he wants to eliminate the step where you perform the cast and just have Dart automagically create meaningful classes from a given pile of JSON data.
I think the performance penalty of this type dancing is obvious: deserialized JSON in JavaScript is already in its purest form, so going and copying bits and pieces of that data into new objects and then performing checks/manipulations on those pieces of data is going to take up a ton of excess memory and bazillions of wasted CPU cycles.
- spankalee 12y agoDeserialized JSON in JavaScript is not necessarily in its most useful form: the objects produced have no useful prototype. Dart already has the equivalent to that with its built-in JSON codec - it deals in Maps and Lists. What the OP is asking for is for deserialization to produce instances of different classes. No matter that it's not possible to map generic JSON structures to classes and objects for anything other than trivial cases (polymorphism, interfaces, heterogenous collections and non-tree structures won't work), JavaScript doesn't produce objects with interesting prototype chains when deserializing JSON, so you'd still have to copy bit around if that's what you want.