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

Serialization and deserialization of structs and other fields #2468

Open
satvikpendem opened this issue Dec 26, 2024 · 2 comments · Fixed by #2470
Open

Serialization and deserialization of structs and other fields #2468

satvikpendem opened this issue Dec 26, 2024 · 2 comments · Fixed by #2470
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc enhancement New feature or request

Comments

@satvikpendem
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I want to use JSON serialization in FRB because I have JSON data I generate on the Rust side and then need to show that in the UI on the Flutter side.

Describe the solution you'd like
There are a few solutions I thought of:

  • Since we already use freezed, we could make freezed be able to generate to and from JSON methods as they are already supported in freezed itself. This is basically Let the generated freezed class be able to have fromJson/toJson #1726.
  • On the Rust side, if we annotate a struct with #[derive(Serialize, Deserialize), perhaps it could be generated automatically on the Dart side just as serde does on the Rust side. The Dart side could even do so via the above freezed way.

Describe alternatives you've considered
Changing the generated code to use the freezed JSON methods or writing it manually in the Dart or Rust code. This can be brittle though, especially changing generated code.

Additional context
NA

@satvikpendem satvikpendem added the enhancement New feature or request label Dec 26, 2024
@fzyzcjy
Copy link
Owner

fzyzcjy commented Dec 26, 2024

I guess the first solution looks good - we only need to add several lines. Feel free to PR for this! Alternatively, I may work on it in the next batch (since this is a new feature instead of a bug).

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Dec 26, 2024
@satvikpendem
Copy link
Contributor Author

Just made a PR: #2470, had a question about tests there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants