Skip to content
New issue

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

@JsonKey on derived attributes #1437

Open
Salvatore95 opened this issue Jul 19, 2024 · 1 comment
Open

@JsonKey on derived attributes #1437

Salvatore95 opened this issue Jul 19, 2024 · 1 comment

Comments

@Salvatore95
Copy link

Salvatore95 commented Jul 19, 2024

I am trying to implement Clean Architecture by keeping Entities separate from Models but I cannot assign JsonKeys to the attributes derived from parent, below is an example of what I would like to achieve:

class Car {
	final String attributeOne;
	final String attributeTwo;
	Car({required this.attributeOne, required this.attributeTwo})
}

@JsonSerializable()
class CarModel extends Car {
	CarModel({
	@JsonKey(name: 'attr_one') required String attrOne, 
	@JsonKey(name: 'attr_two') required String attrTwo,
	}): super(attributeOne: attrOne, attributeTwo: attrTwo),
}

This approach does not work, is there any alternative way?

@kevmoo
Copy link
Collaborator

kevmoo commented Jul 19, 2024

At the moment, no. This is a feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@kevmoo @Salvatore95 and others