detect non finite numbers to emit correct JSON

JSON does not accept NaN or Inf numbers. For this reason we must detect
them and emit null instead.
Merge branch 'F-EmitNullForNonFiniteNumbers'

* F-EmitNullForNonFiniteNumbers:
  detect non finite numbers to emit correct JSON