fjson-dart-bean-generator

Generate Dart @JsonSerializable entity classes and serialization helpers from JSON responses.

656|29|Updated Mar 24, 2024
One-click install
npx skills add https://github.com/K3vinb5/Unyo --skill fjson-dart-bean-generator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fjson-dart-bean-generator
Source: https://github.com/K3vinb5/Unyo/tree/main/.agents/skills/fjson-dart-bean-generator
Command: npx skills add https://github.com/K3vinb5/Unyo --skill fjson-dart-bean-generator

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Manually writing Dart model classes for API JSON responses is repetitive and error-prone, especially when keeping .g.dart serialization helpers and the JsonConvert registry in sync. This Skill automates the entire workflow using the fjson CLI, replacing the FlutterJsonBeanFactory IntelliJ plugin for CLI and agent-based workflows.

Core Features & Use Cases

  • Entity Generation from JSON: Run fjson bean with a class name and JSON string or file to produce a complete @JsonSerializable Dart entity with nested sub-classes, @JSONField annotations, and default field values.
  • Helper Regeneration: Run fjson gen to rebuild all .g.dart files, json_field.dart, and json_convert_content.dart after editing any entity, including cleanup of stale generated files.
  • Use Case: When adding a new AniList API response model to the unyo Flutter project, paste the JSON response, run one command targeting the correct DTO provider folder, and get a ready-to-use entity with all serialization helpers regenerated automatically.

Quick Start

Ask the AI to generate a Dart entity class from your JSON response using the fjson bean command with the class name, JSON payload, output DTO folder, and the --set-default flag.

Frequently Asked Questions about fjson-dart-bean-generator

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

FAQPage Schema
How do I generate Dart model classes from JSON in Flutter?

Run the fjson bean command with --class for the root class name, --json or --file for the payload, --output for the target directory, and --set-default for default field values. It produces a @JsonSerializable entity and automatically regenerates the .g.dart helpers.

How to regenerate .g.dart files after editing a Dart entity?

Run fjson gen with --project pointing to the Flutter project root. It scans lib*.dart for @JsonSerializable classes, rebuilds every .g.dart file, json_field.dart, and json_convert_content.dart, and deletes stale generated files.

Does fjson replace the FlutterJsonBeanFactory IntelliJ plugin?

Yes, the fjson CLI provides the same bean generation and helper regeneration as the FlutterJsonBeanFactory plugin but works from the command line. This makes it suitable for agent workflows and environments without the IDE plugin.

Why does fjson gen not run after fjson bean?

fjson bean only auto-triggers gen when invoked inside a Flutter project containing a pubspec.yaml. If you run it in a non-Flutter directory, you must manually run fjson gen from the project root afterward.

What are the limitations of generating Dart classes from JSON?

Empty JSON arrays cannot have their element type inferred, so fields become List<dynamic> and need manual correction. Class name collisions with existing entities also cause duplicate functions in generated .g.dart files, so check names before running.