otter_json 2.0.3 icon indicating copy to clipboard operation
otter_json: ^2.0.3 copied to clipboard

JSON serialization with code generation. Separate generated code from source and keep everything clean.

Otter JSON

Otter JSON

Maintenance Status

JSON serialization with code generation.

Table of Contents #

Why use it #

Do you suffer from json_serializable? All generated code and 'part' make your source code messy. With Otter JSON, keep everything simple and clean.

Features #

  • Generated code and source code are separated
  • Easy to register new serializer
  • Support all primitives
  • Support flutter common class
  • Support List
  • Support nested object

How to #

  • dependencies
dependencies:
  otter_json:

dev_dependencies:
  build_runner:
  otter_json_generator:
  • annotate
@JSON
class Person {
  String firstName;
  String lastName;
}
  • generate
flutter pub run build_runner build
  • register
Otter.module(GeneratedJsonModule());
  • toJson, fromJson
Map<String, dynamic> map = Otter.toJson(Person());
Person person = Otter.fromJson({});
  • custom serializer
class ColorSerializer implements JsonSerializer<Color, int> {
  @override
  Color decode(int output) {
    return Color(output);
  }

  @override
  int encode(Color input) {
    return input.value;
  }
}

Otter.serializer(ColorSerializer());

otter_json

otter_json_generator

Authors #

2
likes
110
pub points
0%
popularity

Publisher

unverified uploader

JSON serialization with code generation. Separate generated code from source and keep everything clean.

Homepage

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

More

Packages that depend on otter_json