dart-lang / macros

A Dart mono-repo for macro development.
BSD 3-Clause "New" or "Revised" License
54 stars 5 forks source link

Add `package:dart_model` with Json and JsonChanges classes. #1

Closed davidmorgan closed 3 months ago

davidmorgan commented 3 months ago

Add some first package:data_model.

I wanted to avoid anything with schema / generation in the first checkin, so this is just some general JSON handling. The JsonChanges extension types probably will end up in a schema, but I wanted to start somewhere :)

dave26199 commented 3 months ago

Thanks! Replied to design comments now so my brain can iterate on the questions raised :) will make changes and reply fully on Monday.

davidmorgan commented 3 months ago

Made changes, please see what you think :)

This now fits better with what I think is needed for the byte buffer implementation: a JsonData class holding the data and a thin JsonMap class that's a view onto it.

For "applying" changes we probably want something a lot more efficient than copying everything :) I played a bit with approaches where changes are not actually merged into the data but just checked before the underlying data is checked; that should be fast for small changes. But it's quite complicated, not for this PR :)

Thanks.