Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
azuredivay111116hisnt there a "NullValueHandling = NullValueHandling.Ignore" equivalent when deserialising?
-
Lensflare1744713h@antigermanist I know union types (not operators) from typescript.
Declaring multiple possible types doesn‘t help the issue because the decoder still wouldn‘t know what type to use.
All it could do is to try and decode those types one after another until one succeeds.
And that‘s exactly what I am doing with custom decoding.
It‘s not an unsolvable problem. It‘s just shit api design and ugly decoding code. -
@Lensflare say what u want, typescript is pretty nice with this. You could just do something like
type Image = ImageProps | ""' -
@Lensflare but yes if the decoder want static typing that wouldn't work. Weird though, because nothing in the json specs says anything about props having specific types.
-
@Lensflare anyway there's always edge cases. maybe abstract it away at least so it doesn't pollute the main code
-
Lensflare1744712h@antigermanist of course it will be abstracted away. That’s the whole point of the sdk: it provides nice and clean code to access devrant data with nice and clean model types with proper names and structure.
All the dirty mapping and decoding code is hidden.
Though the declarative mapping code can also be seen as doc for the devrant api.
And that‘s where the ugly custom mapping code gets in the way. -
Lensflare1744712h@antigermanist that‘s ok. I mainly write it for myself.
It would be nice if someone else would actually use it but thats unlikely.
Related Rants
Currently implementing a Swift devRant SDK and encountered something very stupid:
The json value for attached image is an object (dictionary) when there is an image but it‘s an empty string "" when there is no image.
So two different types for the same property.
I hate this kind of crap.
Why not make it null or omit that property when there is no image?
Now I need to add ugly as fuck custom decoding code for this object.
devrant
weird
types
api