-
Notifications
You must be signed in to change notification settings - Fork 320
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
Add #[frb(json_key)] annotation to configure/control JSON keys for dart code. #2505
Comments
Looks pretty reasonable and feel free to PR for this! Btw, in your case maybe you want a more automatic solution - https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonSerializable/fieldRename.html? Another potential workaround: do the json serialization on the rust side using e.g. serde. |
@fzyzcjy Should I try to create a PR based on |
I personally think the fieldRename approach is better for your case, because the json_key approach requires to write a lot of annotations. But feel free to choose the one you like! |
I found a better option here |
Looks great! |
Closing this. I don't think it is needed now. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue. |
Is your feature request related to a problem? Please describe.
We generated a dart structure that will have toJosn/fromJson methods. But we can't control the generated key of the JSON. eg
Will generate something similar to
But if we need something similar to
There is no option for that.
Describe the solution you'd like
We can have a
#[frb(json_key=("created_at"))]
annotation to configure/control JSON keys for dart code.The text was updated successfully, but these errors were encountered: