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

rename 'fromMap' and 'toMap' to 'fromJson' and 'toJson' to make compatible with json_serializable #3

Open
TheColdVoid opened this issue Sep 15, 2019 · 6 comments · May be fixed by #30
Labels
enhancement New feature or request

Comments

@TheColdVoid
Copy link

I think better to rename fromMap and toMap to fromJson and toJson to make compatible with the package 'json_serializable'.Package 'json_serializable' need the method named 'fromJson'.Or I think you can provide a setting for the name of serialize method.

@andrasferenczi
Copy link
Owner

I refrained from naming it fromJson / toJson, because the generation does not work recursively. Only the current top-level class properties are put into the map. The properties do not get converted to map, even if they are objects.

Certainly, in your case it might help renaming the method. It will work fine as long as you are just using primitives. But most certainly it will not.

This issue requires a bit more work, since the generator does not know which property is an object / primitive type.

@andrasferenczi andrasferenczi added the enhancement New feature or request label Sep 16, 2019
@TheColdVoid
Copy link
Author

I got it.Thanks.

@andrasferenczi
Copy link
Owner

I think I am also in need of this feature right now.

I am thinking of hardcoding List and Map and primitive types to be serialized in a specific way and rely on all other classes to have a toJson / fromJson as well.

If anyone has any suggestions, feel free to comment

@radoslawsobies
Copy link

it is possible to change name of copyWith method in the settings of this plugin, why not to add such possiblity for toMap and fromMap?

@mtrfnvwork
Copy link

any updates?

@andrasferenczi
Copy link
Owner

No updates. I have still the same opinion as I had before and I don't work anymore in Dart / Flutter. Possibility to rename toMap and fromMap might make sense, but I don't have time to update this plugin.

@hunhee98 hunhee98 linked a pull request Jun 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants