json-serialization

Generate JSON-serializable Dart models with json_serializable and build_runner.

1|Updated Jan 26, 2026
One-click install
npx skills add https://github.com/code-sinobi/hoya-time-travel --skill json-serialization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: json-serialization
Source: https://github.com/code-sinobi/hoya-time-travel/tree/main/.agent/skills/json-serialization
Command: npx skills add https://github.com/code-sinobi/hoya-time-travel --skill json-serialization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill standardizes the creation and maintenance of JSON-serializable models in Dart/Flutter projects, reducing boilerplate and preventing serialization errors.

Core Features & Use Cases

  • Automatic JSON serialization via json_serializable for model classes.
  • Code generation that keeps models in sync with API schemas and storage formats.
  • Use Case: In a Flutter app, generate a User model from an API response and persist it locally with correct serialization.

Quick Start

Create a Dart model annotated with @JsonSerializable and run the code generator to produce the corresponding *.g.dart files.

Frequently Asked Questions about json-serialization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate JSON serialization in Flutter?

Generate JSON serialization in Flutter by annotating model classes with @JsonSerializable and running build_runner to create *.g.dart files. This automates mapping API responses and persisted state to Dart objects.

What is the best way to keep Dart models in sync with API schemas?

The best way to keep Dart models in sync with API schemas is using json_serializable for code generation. It automatically updates serialization logic when you change model annotations, preventing manual mapping errors.

Does json_serializable support immutability for Dart data models?

Yes, json_serializable supports immutability for Dart data models. You can apply annotations to immutable classes to generate standard fromJson and toJson methods without writing boilerplate code.

Why do I need build_runner for Dart JSON serialization?

You need build_runner for Dart JSON serialization to execute the code generator that produces *.g.dart files. It compiles your @JsonSerializable annotations into functional mapping code during development.

When should I use code generation instead of manual JSON parsing in Flutter?

Use code generation instead of manual JSON parsing in Flutter when managing multiple model classes, API responses, or persisted state. It standardizes data models, reduces boilerplate, and prevents serialization errors across your project.