Safe serialization of doubles: NaN and infinite will be represented as null.