@@ -171,8 +171,8 @@ function write(::NumberType, buf, pos, len, y::Integer; kw...)
171
171
end
172
172
173
173
write (:: NumberType , buf, pos, len, x:: T ; kw... ) where {T} = write (NumberType (), buf, pos, len, StructTypes. numbertype (T)(x); kw... )
174
- function write (:: NumberType , buf, pos, len, x:: AbstractFloat ; kw... )
175
- isfinite (x) || error (" $x not allowed to be written in JSON spec" )
174
+ function write (:: NumberType , buf, pos, len, x:: AbstractFloat ; allow_inf :: Bool = false , kw... )
175
+ isfinite (x) || allow_inf || error (" $x not allowed to be written in JSON spec" )
176
176
bytes = codeunits (Base. string (x))
177
177
sz = sizeof (bytes)
178
178
@check sz
@@ -183,8 +183,8 @@ function write(::NumberType, buf, pos, len, x::AbstractFloat; kw...)
183
183
return buf, pos, len
184
184
end
185
185
186
- @inline function write (:: NumberType , buf, pos, len, x:: T ; kw... ) where {T <: Base.IEEEFloat }
187
- isfinite (x) || error (" $x not allowed to be written in JSON spec" )
186
+ @inline function write (:: NumberType , buf, pos, len, x:: T ; allow_inf :: Bool = false , kw... ) where {T <: Base.IEEEFloat }
187
+ isfinite (x) || allow_inf || error (" $x not allowed to be written in JSON spec" )
188
188
@check Parsers. neededdigits (T)
189
189
pos = Parsers. writeshortest (buf, pos, x)
190
190
return buf, pos, len
0 commit comments