Json-to-Dart-Model icon indicating copy to clipboard operation
Json-to-Dart-Model copied to clipboard

enum support

Open Miamoto-Musashi opened this issue 2 years ago • 9 comments

would be nice to have enums support

Miamoto-Musashi avatar Aug 23 '21 12:08 Miamoto-Musashi

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

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

iamarnas avatar Aug 23 '21 15:08 iamarnas

rather than

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

I think is more consistent with rest of notation

{
    "user_status.enum": ["online", "offline" ]
}

Miamoto-Musashi avatar Aug 24 '21 15:08 Miamoto-Musashi

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

Prn-Ice avatar Apr 25 '22 11:04 Prn-Ice

@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 :)

iamarnas avatar Apr 25 '22 12:04 iamarnas

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

Prn-Ice avatar Apr 25 '22 13:04 Prn-Ice

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

iamarnas avatar Apr 25 '22 14:04 iamarnas

Any Update on this one?

globalwebforce avatar Jun 01 '22 10:06 globalwebforce

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

Prn-Ice avatar Aug 28 '22 00:08 Prn-Ice

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

iamarnas avatar Aug 28 '22 08:08 iamarnas