I've created a function that converts a model into JSON using mirror.
Map convertObjectToJson(Object obj);
dynamic convertJsonToObject(Map json, Type type);
I wish to use it so that my models/view-models are converted back and forth between request/response so that I don't have to implement a toJson() method for every model/view-model class.
I'm planning to use shelf_rest. I'm looking at the example on this page: https://pub.dartlang.org/packages/shelf_rest
But I'm not sure how to hook up my methods above so that it will work with shelf_rest's route annotations like the resource below ...
class AccountResource {
@Get('{accountId}')
Account find(String accountId) => new Account.build(accountId: accountId);
}`enter code here`
... but will map the JSON to convert to object before/after the request/response form AccountResource.