hiranthaR / Json-to-Dart-Model

Json to Dart Model extension can convert JSON objects into Dart data classes. It supports pure Dart class conversion, Flutter-recommended JSON serialization using annotations, Freezed support, Effective Dart:Style, and many more features. Currently, it has more than 135,000 installs.
https://marketplace.visualstudio.com/items?itemName=hirantha.json-to-dart
MIT License
93 stars 18 forks source link

enum support #54

Open Miamoto-Musashi opened 3 years ago

Miamoto-Musashi commented 3 years ago

would be nice to have enums support

iamarnas commented 3 years ago

@Miamoto-Musashi I thought about it a long time ago to implement it. String list convert to enum. Example:

{
    "e@user_status": ["online", "offline" ]
}
Miamoto-Musashi commented 3 years ago

rather than

{
    "e@user_status": ["online", "offline" ]
}

I think is more consistent with rest of notation

{
    "user_status.enum": ["online", "offline" ]
}
Prn-Ice commented 2 years ago

Would this be a simple task, I dont use typescript, but I would like to help add this.

iamarnas commented 2 years ago

@Prn-Ice It may be a little tricky, but anything is possible. This source code should be good rewrite to make it easy to implement :)

Prn-Ice commented 2 years ago

I'll play around with it, I'll let you know if I give up.

iamarnas commented 2 years ago

I'll play around with it, I'll let you know if I give up.

Then your tour will be begin in the constructor.ts file, class TypeDefinition ;)

I think it will be enough to include the enum checker annotation and the generator do the rest. Then just add syntax.

I will join to when I will finish one project.

@Prn-Ice

globalwebforce commented 2 years ago

Any Update on this one?

Prn-Ice commented 2 years ago

Sadly I haven't gotten up to this till now. And after finding this package, I'm not sure I'll need to.

iamarnas commented 2 years ago

Sadly I haven't gotten up to this till now. And after finding this package, I'm not sure I'll need to.

If you want to generate enum only with any generator it easy implement. Just need generate a type and generator do the rest. I will look at that. For now I working on another extension as Data Class Generator. It will generate data equal to Freezed by one click, and even regenerate by one click or update automatically on save. Also will be possible make functionality enums. Will be more fun 😁

@Prn-Ice