#Hi,

1 messages · Page 1 of 1 (latest)

clever crater
#

I have a massive JSON to decode, where there is a mix of Doubles and Strings

"densities": [
"NaN",
"NaN",
0.791412353515625,
0.779541015625,
0.781005859375,
0.78570556640625,

If I set my object as a Double, the decode fails, if I set it as a String, it fails, and can't set it to Any...

What's the best option?

Thank you!

clever crater
#

Found a solution, thanks.

scenic sandal
#

Might as well share it here

#

Was it use Float ?

clever crater
scenic sandal
#

Nice enums are powerful

#

Makes me wonder if float would work

#

Since they are both types of float

gloomy sentinel
#

Implement your own decoder and try both

scenic sandal
#

Yeah I might try sometime to see. Been doing non code tasks today but will code soon

mental idol
#

app.quicktype.io is very nice for this kind of problem, at least it is a good start.