My motivation is collecting sensors from the iPad and then sending it to a server. Sometimes the data from the sensors contains Float.infinity which cannot be encoded to JSON by JSONEncoder.
JSONEncoder offers custom strategy called case convertToString(positiveInfinity: String, negativeInfinity: String, nan: String)
which will turn any occurring Float.infinity to the provided custom strings.
However this is not a great solution, because I would like to convert to another Float number like 0 or -9999. Because the server won't accept String instead of Float.
What I would propose is case convertToFloat(positiveInfinity: Float, negativeInfinity: Float, nan: Float).
Does this make sense and do you think this is useful?