Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow_inf and pretty don't play well together #281

Closed
jw3126 opened this issue May 27, 2024 · 2 comments
Closed

allow_inf and pretty don't play well together #281

jw3126 opened this issue May 27, 2024 · 2 comments

Comments

@jw3126
Copy link

jw3126 commented May 27, 2024

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.
@hhaensel
Copy link

Well, just write

JSON3.pretty(JSON3.write((a=Inf, b=1), allow_inf=true), allow_inf=true)

@jw3126
Copy link
Author

jw3126 commented Nov 14, 2024

Thanks!

@jw3126 jw3126 closed this as completed Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants