dart_json_mapper_mobx 2.0.5 copy "dart_json_mapper_mobx: ^2.0.5" to clipboard
dart_json_mapper_mobx: ^2.0.5 copied to clipboard

This is a dart-json-mapper complementary package provides support for MobX Stores to persist as JSON.

pub package

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:

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(['aa@test.com', 'bb@test.com', 'cc@test.com']))
  ));
}

output:

{
  "mailingList": ["aa@test.com","bb@test.com","cc@test.com"]
}
7
likes
150
points
150
downloads

Publisher

verified publisheredensapple.com

Weekly Downloads

This is a dart-json-mapper complementary package provides support for MobX Stores to persist as JSON.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

dart_json_mapper, mobx

More

Packages that depend on dart_json_mapper_mobx