Handle function, NaN, and Infinity like JSON.