google/json_serializable.dart
64.4
Adequate · 19 September 2026
6.8k
lines of production code
Dart
primary language
1
measurement over time
What this system is
This system is a Dart monorepo comprising three interconnected packages: \json\_serializable\, \json\_annotation\, and \checked\_yaml\. It provides code generation tools and runtime annotations for serializing and deserializing Dart objects to and from JSON, while also offering a library for parsing and validating YAML configuration files. The system enforces strict type safety and validation through generated code, supporting complex data structures, custom converters, and schema generation.
How it got here
2017 — Dart 3 migration and modularization
10 changes.
The project migrated to Dart 3.9 and enforced stricter SDK and dependency constraints, while refactoring the internal code generator and runtime helpers into a modular structure. This period also introduced JSON Schema generation support and expanded the example suite to demonstrate advanced serialization patterns.
2018–2019 — test coverage expansion and checked\_yaml introduction
11 changes.
This period focused on significantly expanding test coverage for json\_serializable, adding comprehensive suites for generic classes, default values, and various serialization configurations. It also introduced the new checked\_yaml package for validated YAML decoding, complete with its own test suite and example usage demonstrating integration with json\_serializable.
2020–2022 — CI automation and test coverage expansion
4 changes.
This period focused on strengthening the project's infrastructure and reliability by introducing CI automation scripts for multi-package workflows and expanding test coverage for supported JSON serialization types. It also involved enhancing documentation through automated README generation tools and establishing shared testing utilities to improve debugging and verification processes.
Features
Add CI automation script for multi-package workflows
A new shell script at tool/ci.sh has been added to automate continuous integration tasks across multiple packages. Generated by mono\_repo v6.7.2, this script iterates through packages defined in the PKGS environment variable, handling both Dart and Flutter SDKs by detecting the presence of 'sdk: flutter' in pubspec.yaml. It supports specific tasks including dependency upgrades, code analysis (with optional strictness levels), formatting checks, and various test configurations (standard, skipped tests, Chrome browser tests, and annotation version tests), providing structured output and failure reporting for each package.
tool · high confidence
Add checked\_yaml example demonstrating YAML configuration parsing
The checked\_yaml package now includes an example in the \example/\ directory that demonstrates how to use \checkedYamlDecode\ with \json\_serializable\ to parse and validate YAML configuration files. The example defines a \Configuration\ class with required and optional fields, showing how to handle missing keys and type conversion while enforcing validation rules.
_checked\yaml/example · high confidence
Example demonstrates JSON Schema generation capability
The json\_serializable example now includes a Person class that utilizes the createJsonSchema option to automatically generate a JSON Schema definition alongside the standard serialization methods. Users can see how to access the generated schema via a static const field, illustrating the library's ability to produce schema metadata for data models.
_json\serializable/example · high confidence
Introduce checked\_yaml library for validated YAML decoding
The checked\_yaml package is introduced, providing a \checkedYamlDecode\ function that parses YAML content and validates it against a constructor. This library enhances error reporting by wrapping parsing and validation errors in \ParsedYamlException\, which includes source location information (via \YamlNode\) to help users identify issues in their YAML files, such as missing keys, unrecognized keys, or unsupported values.
_checked\yaml/lib · high confidence
Introduce code generators for automated test and documentation scaffolding
The \json\_serializable/tool\ directory now includes a suite of \build\_runner\ builders that automatically generate test fixtures and documentation content. \test\_builder\ and \test\_type\_builder\ create parameterized test classes for various supported types (including collections, records, and generics) and configuration options (such as \anyMap\ and \checked\), while \readme\_builder\ populates the README with up-to-date type lists and links. These tools reduce manual maintenance of test coverage and documentation by generating the necessary boilerplate code and markdown replacements during the build process.
_json\serializable/tool · high confidence
New README generation tooling and updated documentation examples
The package now includes a new tooling setup in the \tool/readme\ directory to automate README generation. This introduces \readme\_examples.dart\ and its generated counterpart \readme\_examples.g.dart\, which provide concrete code samples for the documentation, covering simple enums, enhanced enums with value fields, custom \fromJson\/\toJson\ methods, \JsonKey\ conversions, and \JsonConverter\ implementations. The \readme\_template.md\ file serves as the source for the main README, incorporating these examples via placeholders and adding a new section on JSON Schema generation (enabled via \createJsonSchema: true\), detailing how schemas are created as static constants with type mapping and documentation support.
_json\serializable/tool/readme · high confidence
New example files added to demonstrate advanced serialization patterns
The example/lib directory now includes several new Dart source files and their generated counterparts that demonstrate advanced usage of the json\_serializable package. These additions cover handling generic response objects with custom data inspection, using JsonConverter for custom type encoding (such as DateTime to epoch integers), managing nested list structures via custom converters, and serializing generic tuples with genericArgumentFactories. A new data.json file is also included to support the glossary literal example.
example/lib · high confidence
Behavioural changes
Consolidated JSON annotation library exports
The json\_annotation package now provides a single entry point that exports all annotation classes and helper functions. Users can import the main library to access core annotations like JsonSerializable and JsonEnum, as well as helper utilities for enum conversion, key/value mapping, and custom type conversion (JsonConverter).
_json\annotation/lib · high confidence
Refactored runtime helpers into dedicated source files
The runtime support code used by the code generator has been reorganized into separate files within the \json\_annotation\ package. Helper functions for checked deserialization (\$checkedCreate\, \$checkedNew\, \$checkedConvert\) and key validation (\$checkKeys\) are now in \checked\_helpers.dart\ and \allowed\_keys\_helpers.dart\, while enum decoding utilities (\$enumDecode\, \$enumDecodeNullable\) have been moved to \enum\_helpers.dart\. This change also introduces new exception classes (\UnrecognizedKeysException\, \MissingRequiredKeysException\, \DisallowedNullValueException\) and a base \BadKeyException\ in \allowed\_keys\_helpers.dart\ to provide more specific error reporting during deserialization, and moves the \JsonConverter\ abstract class to its own file.
_json\annotation/lib/src · high confidence
Refactored type helpers and configuration into a modular structure
The internal implementation of the code generator has been reorganized to improve maintainability and support new features. Configuration logic for \@JsonSerializable\ and \@JsonKey\ annotations has been extracted into dedicated \config\_types.dart\ files (\ClassConfig\, \KeyConfig\), replacing previous inline parsing. Type serialization and deserialization logic is now split into granular, single-responsibility helper classes (e.g., \BigIntHelper\, \DateTimeHelper\, \DurationHelper\, \EnumHelper\, \IterableHelper\, \MapHelper\, \RecordHelper\, \JsonConverterHelper\, etc.) located in the \type\_helpers\ directory. This change also introduces support for Dart 3 Record types via \RecordHelper\, adds a \BigIntHelper\ for \BigInt\ serialization, and refactors \DateTime\ handling to respect the \dateTimeUtc\ configuration option. The \TypeHelper\ interface and context objects have been updated to pass richer configuration context to these helpers.
_json\_serializable/lib/src/type\helpers · high confidence
Restructured public API exports and builder configuration
The library's public API has been reorganized to improve clarity and modularity. The main \json\_serializable.dart\ file now explicitly exports only the core generator classes (\JsonEnumGenerator\, \JsonLiteralGenerator\, \JsonSerializableGenerator\), while \type\_helper.dart\ serves as the dedicated entry point for all type helper implementations and context classes. Additionally, \builder.dart\ now provides a cleaner interface for \build\_runner\ integration, including improved error handling for invalid configuration options and the removal of internal \run\_only\_if\_triggered\ flags from user-facing config parsing.
_json\serializable/lib · high confidence
json\_serializable now requires Dart 3.8 and validates the json\_annotation dependency version
The code generator now enforces a minimum Dart SDK version of 3.8.0, as the generated code utilizes null-aware elements introduced in that release. Additionally, a new dependency check ensures that the \json\_annotation\ package is present in the project's dependencies with a minimum version of 4.12.0, warning users if the constraint is missing or too low.
_json\serializable/lib/src · high confidence
Test coverage
Added comprehensive test suite for json\_serializable; Added shared test utilities and mono\_repo configuration; Added test source definitions for JSON serialization configuration scenarios; Added tests for YAML configuration parsing and build verification; Added tests for checked\_yaml; Added tests for default value handling in json\_serializable; Added tests for example code; Added tests for generic class serialization and generic argument factories; Added tests for the @JsonLiteral code generator; Expanded test coverage for supported JSON serialization types; Integration tests for new serialization features and regression fixes; Kitchen sink tests now cover multiple serialization configurations.
Dependencies
Migrate to Dart 3.9 SDK and Dart workspaces
The project has updated its minimum SDK constraint to ^3.9.0 across all packages and enabled Dart's native workspace resolution. This migration consolidates the monorepo structure, allowing shared dependency management and unified tooling for packages such as json\_serializable, json\_annotation, and checked\_yaml.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 64.
Lenses
- Code Health 93
- Architecture 100
- Maturity 49
- Readiness 74
- Security 70
- Domain Modelling 100
Changes since last survey
- 300 commits — 253 feature/other, 47 fixes
By area
- .github/workflows — 81 commits
- json_serializable/test — 64 commits
- json_serializable/lib — 43 commits
- json_serializable/CHANGELOG.md — 28 commits
- (root) — 11 commits
- json_annotation/CHANGELOG.md — 11 commits
- json_annotation/lib — 7 commits
- json_serializable/README.md — 7 commits
- json_serializable/tool — 7 commits
- checked_yaml/pubspec.yaml — 6 commits
- example/README.md — 6 commits
- example/lib — 5 commits
- .github/dependabot.yml — 3 commits
- _test_yaml/pubspec.yaml — 3 commits
- checked_yaml/CHANGELOG.md — 3 commits
- (repo) — 2 commits
- json_serializable/pubspec.yaml — 2 commits
- .github/ISSUE_TEMPLATE.md — 1 commit
- .github/markdown-link-check-config.json — 1 commit
- .github/no-response.yml — 1 commit
Notable commits
- fix: CI fix to handle analyzer/SDK language version changing (#1513)
- fix: CI: fix markdown lint (#1389)
- fix: Enable and fix a few more lints (#954)
- fix: Enable and fix new lints (#1274)
- fix: Enable and fix unnecessary_ignore lint (#1477)
- fix: Fix BigInt, DateTime, Uri JsonKey.defaultValue w/ a function (#1220)
- fix: Fix JsonConverter docs example (#1193)
- fix: Fix a bug when annotated classes also use mixins (#1211)
- fix: Fix actions in markdown_linter (#1240)
- fix: Fix bug running code generation for classes inheriting from ListBase (#1514)
- fix: Fix bug when JsonKey.includeToJson is false (#1281)
- fix: Fix build (#1225)
- fix: Fix encoding nullable values with converters, prepare for release (#1231)
- fix: Fix enum support for upcoming enhanced enums in Dart 2.17 (#1111)
- fix: Fix extra line with Dart 3.7 syntax (#1478)
- fix: Fix for latest analyzer (#1487)
- fix: Fix handling of nullable enum fields with includeIfNull: false (#1227)
- fix: Fix issue with nested generics and genericArgumentFactories: true
- fix: Fix lints and docs (#1457)
- fix: Fix new lint (#1546)
- …and 280 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
google/json_serializable.dart was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit aa4fa9936f93ccdc22369c970032a8d5eaa547c1 — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.