json_serializable_mobx
1.1.3, released 10 months ago by demoda.app
Extends json_serializable to support MobX collections like ObservableList, ObservableSet, and ObservableMap.
What it does
It adds support for serializing and deserializing MobX collections using the json_serializable code generation tool. It acts as an extension to allow seamless handling of reactive collections in data models.
AI-written summary of version 1.1.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are using MobX in your Flutter application and need to serialize models containing ObservableList, ObservableSet, or ObservableMap.
- You already rely on json_serializable for your JSON parsing boilerplate.
Skip it when
- You are not using MobX for state management.
- You prefer manual JSON serialization or a different code generation library like built_value.
Strengths
- Bridges MobX collections with json_serializable seamlessly.
- Reduces manual mapping boilerplate for reactive types.
Weaknesses
- Requires custom build.yaml configuration to avoid conflicts with standard json_serializable.
- Unofficial package dependent on json_serializable internals.
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 7
Requires adding to dev_dependencies and configuring build.yaml to exclude standard json_serializable builders and avoid conflicts.
targets:
$default:
builders:
json_serializable_mobx:
options:
explicit_to_json: true
json_serializable:json_serializable:
generate_for:
include:
exclude:
- test/**
- lib/**Alternatives
Packages that do the same job and could replace json_serializable_mobx.
- built_value
Alternative code generation system for immutable values and JSON serialization.
88Compare
Works with
Packages commonly used together with json_serializable_mobx: ones it builds on, ones built on it, and its own family.
- analyzerjson_serializable_mobx depends on itPerforms static analysis of Dart code for tool integration and embedding.
- json_annotationjson_serializable_mobx depends on itProvides annotations for json_serializable to generate JSON (de)serialization code.
- buildjson_serializable_mobx depends on itPackage for authoring build_runner compatible code generators.
- build_runnerjson_serializable_mobx depends on itA build system for Dart code generation and modular compilation.
- source_genjson_serializable_mobx depends on itSource code generation builders and utilities for the Dart build system.
- json_serializablejson_serializable_mobx depends on itAutomatically generate code for converting Dart classes to and from JSON.
- json_serializable_immutable_collectionsSame familyExtends json_serializable to support immutable collections like BuiltList and KtList.