We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to use jsonkey to generate a line like this firstName: json ['customKey']['firstName'] as String,
Let's say I have an object like this from the server.
{ customKey : { firstName: ' MyFirstName' lastName: 'MyLastName' }, dateOfBirth: '1997-12-17T03:24:00' }
And I want to create a Flutter Class like this
@JsonSerializable(nullable: false) class Person { final String firstName; final String lastName; final DateTime dateOfBirth; Person({this.firstName, this.lastName, this.dateOfBirth}); factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json); Map<String, dynamic> toJson() => _$PersonToJson(this); }
Person _$PersonFromJson(Map<String, dynamic> json) { return Person( **firstName: json['customKey']['firstName'] as String,** **lastName: json['customKey']['lastName'] as String,** dateOfBirth: DateTime.parse(json['dateOfBirth'] as String), ); } Map<String, dynamic> _$PersonToJson(Person instance) => <String, dynamic>{ 'firstName': instance.firstName, 'lastName': instance.lastName, 'dateOfBirth': instance.dateOfBirth.toIso8601String(), };
The text was updated successfully, but these errors were encountered:
Duplicate of #490
Sorry, something went wrong.
No branches or pull requests
Is it possible to use jsonkey to generate a line like this firstName: json ['customKey']['firstName'] as String,
Let's say I have an object like this from the server.
And I want to create a Flutter Class like this
The text was updated successfully, but these errors were encountered: