javiercbk / json_to_dart

Library that generates dart classes from json strings
https://javiercbk.github.io/json_to_dart/
The Unlicense
1.33k stars 371 forks source link

Provide hints to the generator to overwrite types #45

Open choiruru opened 4 years ago

choiruru commented 4 years ago

hi @javiercbk , Thanks for your awesome project, it is very helpful and saving much time when I want to generate json as dart class model.

But, sometime I found a weird json like this

[
    {
        "volume":123
    },
    {
        "volume":123.5
    },
    {
        "volume":null
    } 
]

it will be awesome if there is an option to cast all int and double as String in your project.. thank you

javiercbk commented 4 years ago

Actually the library supports this but the frontend does not. I thought about providing hint to the generator and force it to choose a type even though it was not the one that it had detected.

this should be implemented in the frontend but sadly it is not a trivial amount of work.