json_model
1.0.0, released 5 years ago by an unverified publisher
Generate Dart model classes from JSON files with a single command.
What it does
Parses JSON files stored in a designated directory and automatically generates corresponding Dart model classes complete with json_serializable support. It allows referencing other models via special syntax and configuring rules through metadata inside the JSON files.
AI-written summary of version 1.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You prefer maintaining raw JSON files instead of UI tools or Dart classes for data structures
- You want to generate JSON serialization code effortlessly using a command line tool
Skip it when
- You prefer writing your immutable Dart models manually using tools like freezed or json_annotation
- You need complex custom serialization logic that cannot be derived from a raw JSON file structure
Strengths
- Keeps raw JSON files as the single source of truth for your models
- Supports referencing other models and arrays using a simple syntax
- Allows fine-tuning generation rules via `$meta` configurations and ignores
Weaknesses
- License is unknown
- Relies on external JSON files rather than Dart-first code definitions
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- Yes (build_runner)
- Direct dependencies
- 8
Add json_model and json_serializable to dev_dependencies and run via pub run json_model.
import 'package:json_model/json_model.dart';
void main() {
run(['src=jsons']);
}Alternatives
Packages that do the same job and could replace json_model.
- freezed_annotation
Pick freezed if you prefer defining models in Dart code with immutability and union types rather than managing separate raw JSON files.
78Compare - json_annotation
Pick json_annotation with json_serializable if you want to write standard Dart classes and annotate them directly for JSON serialization.
84Compare
Works with
Packages commonly used together with json_model: ones it builds on, ones built on it, and its own family.
- globjson_model depends on itA file and directory globbing library that supports Bash-style path matching and listing.
- iojson_model depends on itUtilities for the Dart VM Runtime including ANSI colors, file copying, and exit code values.
- argsjson_model depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- loggingjson_model depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- buildjson_model depends on itPackage for authoring build_runner compatible code generators.
- build_runnerjson_model depends on itA build system for Dart code generation and modular compilation.