Closed vojtabohm closed 5 years ago
The save function won't get the encoder parameter from the append function
Please try pod 'Disk', '~> 0.6.2'
and let me know if that works for you. Thanks
Although it seems like it is getting passed (I cannot debug it except visually) it still doesn't work. Still getting
"Unable to encode Float.nan directly in JSON. Use JSONEncoder.NonConformingFloatEncodingStrategy.convertToString to specify how the value should be encoded."
Which is what I wanted to prevent using a custom encoder that has this strategy and gets passed into Disk.
I figured out what was wrong. When the encoder sees Float.NaN or Float.infinity it will convert it to "0" (my custom encoder that is being correctly passed now).
However when appending, the Disk library decodes the past data and tries to append the new data. The old data has "0" instead of a Float so that's why it failed.
If anyone ever stumbles upon this issue: Make sure to also pass custom Decoder with nonConformingFloatDecoding strategy! :D
Thank you saoudrizwan for fixing this issue!
When I want to pass encoder with custom nonConformingFloatEncodingStrategy to Disk.append, it will not get passed inside the function to the Disk.save function. The encoder parameter is there but it has a default value and is not overwritten.
I think this should be added.