Skip to content
pubscout

json_model

1.0.0, released 5 years ago by an unverified publisher

Generate Dart model classes from JSON files with a single command.

Quiet but busy
$ flutter pub add json_model
Source repository

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.

  • json_annotation

    Pick json_annotation with json_serializable if you want to write standard Dart classes and annotate them directly for JSON serialization.

Works with

Packages commonly used together with json_model: ones it builds on, ones built on it, and its own family.