Build Status pub package

This is a dart-json-mapper complementary package provides support for http://mobx.pub 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: any
  dart_json_mapper_mobx: any
dev_dependencies:
  build_runner: any

Usage example lib/main.dart

import 'package:dart_json_mapper/annotations.dart';
import 'package:dart_json_mapper/json_mapper.dart';
import 'package:mobx/mobx.dart';
import 'package:dart_json_mapper_mobx/dart_json_mapper_mobx.dart';

import 'main.reflectable.dart'; // Import generated code.

@jsonSerializable
class MyMobXClass {
  ObservableList<String> mailingList = ObservableList<String>();

  MyMobXClass(this.mailingList);
}

main() {
  initializeReflectable(); // Imported from main.reflectable.dart
  initializeJsonMapperForMobX(); // Imported from dart_json_mapper_mobx
  
  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"]
}

Libraries

json_mapper_mobx