json_serializable.dart
json_serializable.dart copied to clipboard
Generates utilities to aid in serializing to/from JSON.
Hi. I am having trouble in converting a json returned from API to the respective model. I am using the Generic class. When I try to parse `T.fromJson(x)` it gives...
Related to https://github.com/a14n/dart-decimal/issues/59#issuecomment-1204739053.
It would be very useful to create a reversed enum map: ```dart @JsonEnum() enum MyEnum { a, b, } ``` What is currently generated: ```dart const _$MobileScreenNameEnumMap = { MyEnum.a:...
``` @JsonSerializable() class VersionInfo { VersionInfo(); /// @JsonKey(name: "v_CreateTime") String? vCreateTime = ''; /// @JsonKey(name: "v_Identity") num? vIdentity = 0; } ``` v_Identity is null ,the vIdetity set 0
I would like to supply a `DateTime.now()` as a `defaultValue` to `JsonKey`, but as it's not a `const` it's not possible to add it, however if it was of type...
We have now [support](https://github.com/google/json_serializable.dart/issues/929) for `fieldRename` on a per-enum basis (rather than per-value), which simplifies the setup. In our case, all enums coming from the backend are serialized in PascalCase,...
If for some reason an API returns another type than expected, you get an (e.g.) `type '_GrowableList' is not a subtype of type 'Map?' in type cast` error. I know...
A use case is when using constructs such as `Optional` or `Option`. For example: ```dart import 'package:json_annotation/json_annotation.dart'; part 'example.g.dart'; @JsonSerializable(includeIfNull: false) class Person { final String firstName; @JsonKey(includeIfNull: false) final...
Hello. I am facing the problem when I am using new Dart 2.17 super-parameters in constructor. ```dart const BasketModel({ required this.products, required this.delayedProducts, required this.unavailableProducts, required super.coupon, required super.couponData, required...
I have a problem with including the field that overrides my child's class toJson method ``` abstract class Parent { abstract String type; } @JsonSerializable() class Child extends Parent {...