JsonToKotlinClass
JsonToKotlinClass copied to clipboard
Request: Add settings option to supress Any types in favour of Strings.
The reason being I can't parcelize a data class with Any types in them.
Cheers.
@occultus73 Hi, Can you show some examples or demos?
Oh it's very simple really: when the plugin is fed null json property, it cannot of course infer the data type from a null so the corresponding Kotlin property that is generated has a type of "Any"
Changing nulls to produce String instead of Any for null would only be a matter of one carefully placed IF statement somewhere, I would have thought... and a new button in settings.
@occultus73 Got it,But maybe null is a real object in future API response, Then May JSONObject can't cast to String, And It will broken in program,right?
@occultus73 It's easy to achieve your goal, Just create an Extension for the plugin is OK.
Change Type Any
to String
when Property#originJSONValue is null
That is true. I think 9/10 instances it's a string. But then again over a very large data model that 1/10 is bound to come along.
Perhaps this setting wouldn't be so helpful after all. 😐
@occultus73 Haha, Welcome to create a pull request for this, It's also an acceptable option to replace Any with String when json value is nul