0 purchases
dart json mapper mobx
This is a dart-json-mapper complementary package provides support for MobX.dart classes in order to serialize / deserialize them from / to JSON.
Basic setup #
Beforehand please consult with basic setup section from dart-json-mapper package.
Please add the following dependencies to your pubspec.yaml:
dependencies:
dart_json_mapper:
dart_json_mapper_mobx:
dev_dependencies:
build_runner:
copied to clipboard
Usage example
lib/main.dart
import 'package:mobx/mobx.dart' show ObservableList;
import 'package:dart_json_mapper/dart_json_mapper.dart' show JsonMapper, jsonSerializable;
import 'package:dart_json_mapper_mobx/dart_json_mapper_mobx.dart' show mobXAdapter;
import 'main.mapper.g.dart' show initializeJsonMapper;
@jsonSerializable
class MyMobXClass {
ObservableList<String> mailingList = ObservableList<String>();
MyMobXClass(this.mailingList);
}
void main() {
initializeJsonMapper(adapters: [mobXAdapter]);
print(JsonMapper.serialize(
MyMobXClass(ObservableList<String>.of(['[email protected]', '[email protected]', '[email protected]']))
));
}
copied to clipboard
output:
{
"mailingList": ["[email protected]","[email protected]","[email protected]"]
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.