Solve problem with NaN values not being serialized to valid JSON.