json_serializable.dart icon indicating copy to clipboard operation
json_serializable.dart copied to clipboard

[Feature Request] list name

Open 1AlexFix1 opened this issue 3 years ago • 3 comments

Hello, sometimes i need to have a list of different names for values @JsonKey(name: ['firstName' , 'altertativeName'])

codogen json['firstNane'] ?? json['altertativeName']

1AlexFix1 avatar Jul 26 '22 11:07 1AlexFix1

Do you mean something like that https://github.com/k-paxian/dart-json-mapper#name-aliases-configuration ?

k-paxian avatar Jul 28 '22 10:07 k-paxian

k

yes)) as I understand it, this is your add-on to the current package

1AlexFix1 avatar Jul 29 '22 01:07 1AlexFix1

Nope, unfortunately it's a different independent package

k-paxian avatar Jul 29 '22 06:07 k-paxian

Use https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/readValue.html – this is a general solution for this case.

kevmoo avatar Oct 04 '22 02:10 kevmoo