quinnj / JSON3.jl

Other
214 stars 47 forks source link

allow_inf and pretty don't play well together #281

Open jw3126 opened 4 months ago

jw3126 commented 4 months ago
JSON3.pretty(JSON3.write((a=Inf, b=1), allow_inf=true))
{
ERROR: ArgumentError: invalid JSON at byte position 6 while parsing type Any: InvalidChar
{"a":Infinity,"b":1}

Stacktrace:
  [1] invalid(error::JSON3.Error, buf::Base.CodeUnits{UInt8, String}, pos::Int64, T::Type)
    @ JSON3 ~/.julia/packages/JSON3/jSAdy/src/JSON3.jl:30
  [2] read!(buf::Base.CodeUnits{…}, pos::Int64, len::Int64, b::UInt8, tape::Vector{…}, tapeidx::Int
64, ::Type{…}, checkint::Bool; allow_inf::Bool)
    @ JSON3 ~/.julia/packages/JSON3/jSAdy/src/read.jl:139
  [3] read!(buf::Base.CodeUnits{…}, pos::Int64, len::Int64, b::UInt8, tape::Vector{…}, tapeidx::Int
64, ::Type{…}, checkint::Bool; kw::@Kwargs{…})
    @ JSON3 ~/.julia/packages/JSON3/jSAdy/src/read.jl:278
  [4] read!(buf::Base.CodeUnits{…}, pos::Int64, len::Int64, b::UInt8, tape::Vector{…}, tapeidx::Int
64, ::Type{…}, checkint::Bool; allow_inf::Bool)
    @ JSON3 ~/.julia/packages/JSON3/jSAdy/src/read.jl:89
  [5] read!
    @ ~/.julia/packages/JSON3/jSAdy/src/read.jl:87 [inlined]
  [6] read(json::String; jsonlines::Bool, numbertype::Nothing, kw::@Kwargs{})
    @ JSON3 ~/.julia/packages/JSON3/jSAdy/src/read.jl:57
  [7] read
    @ ~/.julia/packages/JSON3/jSAdy/src/read.jl:30 [inlined]
  [8] pretty(out::Base.TTY, str::String, ac::JSON3.AlignmentContext; kw::@Kwargs{})
    @ JSON3 ~/.julia/packages/JSON3/jSAdy/src/pretty.jl:68
  [9] pretty(out::Base.TTY, str::String, ac::JSON3.AlignmentContext)
    @ JSON3 ~/.julia/packages/JSON3/jSAdy/src/pretty.jl:55
 [10] pretty(str::String, ac::JSON3.AlignmentContext; kw::@Kwargs{})
    @ JSON3 ~/.julia/packages/JSON3/jSAdy/src/pretty.jl:53
 [11] pretty
    @ ~/.julia/packages/JSON3/jSAdy/src/pretty.jl:53 [inlined]
 [12] pretty(str::String)
    @ JSON3 ~/.julia/packages/JSON3/jSAdy/src/pretty.jl:53
 [13] top-level scope
    @ REPL[44]:1
Some type information was truncated. Use `show(err)` to see complete types.