dart_serializer 1.0.4 copy "dart_serializer: ^1.0.4" to clipboard
dart_serializer: ^1.0.4 copied to clipboard

"A Dart package designed to streamline the creation of Dart data models from JSON files using a convenient command-line interface (CLI)."

dart_serializer #

dart_serializer is a Dart package designed to streamline the creation of Dart data models from JSON files using a convenient command-line interface (CLI). It simplifies the process of generating Dart classes that accurately represent the structure of JSON data, making it easier to work with JSON APIs and datasets in Dart projects.

Features #

  • Automatic Dart Class Generation: Quickly generate Dart classes from JSON files.
  • Support for Nested Structures: Handle nested objects, arrays, and diverse data types effortlessly.
  • Customizable Naming Conventions: Adapt class and field names to suit your project's conventions.
  • Seamless CLI Integration: Easily incorporate data model generation into your workflow.

Installation #

Ensure you have Dart installed on your system. If not, download it from the Dart website. Once Dart is installed, activate dart_serializer globally:

Usage #

After installing dart_serializer, you can use the dart run dart_serializer:generate command-line tool to generate Dart data models from JSON files. Here's how you can use it:

  1. Prepare Your JSON File: Create a JSON file defining the structure of your data. For example, example.json:

    {
      "name": "John Doe",
      "age": 30,
      "address": {
        "street": "123 Main St",
        "city": "Anytown",
        "state": "Anystate",
        "zipcode": "12345"
      }
    }
    
  2. Run the dart run dart_serializer:generate path/to/your/file.dart command with the path to your JSON file as an argument:

  3. dart_serializer will generate Dart classes based on the structure of your JSON data. The generated classes will be saved in the current directory.

  4. You can now use the generated Dart classes in your Dart code to parse JSON data into Dart objects and vice versa.

  5. Null Safety: You can also generate Nullable Dart classes by passing nullable argument. For example, dart run dart_serializer:generate path/to/your/file.dart nullable

Contributing #

If you encounter any issues or have suggestions for improvement, feel free to open an issue or submit a pull request on GitHub.

License #

This project is licensed under the MIT License - see the LICENSE file for details.

4
likes
130
points
41
downloads

Publisher

unverified uploader

Weekly Downloads

"A Dart package designed to streamline the creation of Dart data models from JSON files using a convenient command-line interface (CLI)."

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on dart_serializer