[issue40633] json.dumps() should encode float number NaN to null

2020-05-16 Thread Haoyu SUN
Haoyu SUN added the comment: About using null in JSON to represnet NaN value of a float type, I prefer this logic: float is a numeric type that expecting a number as its value, "Not a Number" on a numeric type is equivalent to None (¬Number ∩ NumericValues = Empty). If we need to

[issue40633] json.dumps() should encode float number NaN to null

2020-05-15 Thread Haoyu SUN
Haoyu SUN added the comment: Thank you for the timely reply, Eric. How about we add an optional argument (like the argument "ignore_nan" defaults to False as the package simplejson does) to functions like json.dumps(). So that user can choose whether he needs NaN encoded as N

[issue40633] json.dumps() should encode float number NaN to null

2020-05-15 Thread Haoyu SUN
New submission from Haoyu SUN : Float numbers in Python can have 3 special number: nan, inf, -inf, which are encoded by json module as "NaN", "Infinity", "-Infinity". These representations are not compatible with JSON specifications RFC7159: https://tools.iet