-
I have a use case of backing up all key/values from It worked on Android, but not on Desktop, since getIntOrNull, always returns 0, if value of another type. I found that code does mention that behavior is undefined in this case, so wanted to know if there is a better way to approach this, was trying not to get into expect/actual into platform specific impl, to get export working. So, is there a better way to do this ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
There's not really a good built-in for this, sorry. I explicitly left that behavior undefined to avoid the complication of massaging every platform API to have the same behavior since there's so many little edge-cases there. If you know all possible keys and types explicitly, you can probably do something clever with the serialization extension to convert to json. But if you know that then you wouldn't need to iterate the way you are. One option might be to store everything as strings, assuming you have the flexibility to change that. |
Beta Was this translation helpful? Give feedback.
There's not really a good built-in for this, sorry. I explicitly left that behavior undefined to avoid the complication of massaging every platform API to have the same behavior since there's so many little edge-cases there.
If you know all possible keys and types explicitly, you can probably do something clever with the serialization extension to convert to json. But if you know that then you wouldn't need to iterate the way you are.
One option might be to store everything as strings, assuming you have the flexibility to change that.