google / google/json_serializable.dart

Allow default value encoded as JSON or as the default constructor

Open
#1,575 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
1.6k
Forks
461
Avg merge
45m
Merged PRs (30d)
1

Description

Consider this :
```
class InnerClass {
int field = 0;
int otherField = 0;
}

class OuterClass {
InnerClass innerClass = InnerClass();
// other fields
}
```

I can't set a default value for `innerClass`. I can edit the generated file of course, but that's annoying.
Dart semantics don't allow non-const values in annotations from my understanding, so a specific annotation field such as `includeFromJson` would be required.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.