dart_json_mapper_mobx 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 82

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:mobx/mobx.dart';
import 'package:dart_json_mapper/dart_json_mapper.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"]
}

1.0.1 #

  • mobx version bump

1.0.0 #

  • pedantic linter adopted

0.1.0 #

  • Added support for Observable, ObservableList, ObservableSet, ObservableMap

0.0.1 #

  • Added support for ObservableList<T>, where T in
[String, bool, num, int, double, DateTime]

example/example.dart

library json_mapper_mobx.example;

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

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

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

  MobX(this.mailingList);
}

void main() {
  initializeReflectable();
  initializeJsonMapperForMobX();

  final m = MobX(
      ObservableList<String>.of(['aa@test.com', 'bb@test.com', 'cc@test.com']));
  final targetJson = JsonMapper.serialize(m, SerializationOptions(indent: ''));
  final instance = JsonMapper.deserialize<MobX>(targetJson);

  // Serialized object
  print(targetJson);

  // Deserialize object
  print(instance);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_json_mapper_mobx: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_json_mapper_mobx/dart_json_mapper_mobx.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
65
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
82
Learn more about scoring.

We analyzed this package on Jan 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.1 <3.0.0
dart_json_mapper >=1.2.10 <3.0.0 1.3.3
mobx ^0.4.0+1 0.4.0+1
Transitive dependencies
analyzer 0.38.5 0.39.4
args 1.5.2
async 2.4.0
build 1.2.2
build_config 0.4.1+1
build_daemon 2.1.3
build_resolvers 1.2.1 1.3.1
build_runner_core 4.3.0
built_collection 4.3.2
built_value 7.0.8
charcode 1.1.2
checked_yaml 1.0.2
code_builder 3.2.1
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
dart_style 1.3.3
fixnum 0.10.11
front_end 0.1.27 0.1.29
glob 1.2.0
graphs 0.2.0
html 0.14.0+3
http 0.12.0+4
http_multi_server 2.1.0
http_parser 3.1.3
intl 0.16.1
io 0.3.3
js 0.6.1+1
json_annotation 3.0.1
kernel 0.3.27 0.3.29
logging 0.11.4
matcher 0.12.6
meta 1.1.8
mime 0.9.6+3
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
package_resolver 1.0.10
path 1.6.4
pool 1.4.0
pub_semver 1.4.2
pubspec_parse 0.1.5
quiver 2.1.2+1
reflectable 2.2.0 2.2.1+2
shelf 0.7.5
shelf_web_socket 0.2.3
source_span 1.6.0
stack_trace 1.9.3
stream_channel 2.0.0
stream_transform 1.1.0
string_scanner 1.0.5
term_glyph 1.1.0
timing 0.1.1+2
typed_data 1.1.6
watcher 0.9.7+13
web_socket_channel 1.1.0
yaml 2.2.0
Dev dependencies
build_runner any 1.7.3
build_test any
pedantic ^1.9.0 1.9.0
test any