Skip to content

Conversation

@quinnj
Copy link
Contributor

@quinnj quinnj commented Oct 3, 2025

No description provided.

ft = typeof(field)
value = ft <: get(SUPPORTED_TYPES, nameof(ft), Union{}) ? JSON.lower(field) : field
d[name] = value
d[name] = value isa Float64 && !isfinite(value) ? nothing : value
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a surprise to me; I didn't realize JSON pre-1.0 allowed writing Inf out by default (which is against JSON spec) as null. I tried to think about other ways we could try and compat this, but I think this is simplest.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python does

>>> import json, math
>>> json.dumps(math.inf)
'Infinity'

@quinnj quinnj force-pushed the jq-json-1.0 branch 4 times, most recently from 225e4e0 to 7dbf408 Compare October 3, 2025 22:50
Copy link
Contributor

@odow odow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 this is blocking JuMP from updating to JSON@1

@quinnj
Copy link
Contributor Author

quinnj commented Oct 6, 2025

Not sure who is best to merge; @willow-ahrens perhaps?

@odow
Copy link
Contributor

odow commented Oct 14, 2025

I guess @vchuravy has commit permissions.

@willow-ahrens
Copy link
Collaborator

This looks great, do you also need a new release?

@quinnj
Copy link
Contributor Author

quinnj commented Oct 14, 2025

Yes

@odow
Copy link
Contributor

odow commented Oct 14, 2025

Not sure what's going on with the queued job. But do we really need to test v1.7 on ubuntu 20.04?

@maleadt maleadt merged commit 698d2bd into JuliaCI:main Oct 16, 2025
9 of 10 checks passed
@vtjnash
Copy link
Member

vtjnash commented Oct 16, 2025

I haven't investigate far yet, but this new release appears to be a breaking change that causes BaseBenchmarks to now fail. We might need to yank this version?

      From worker 3:    ERROR: LoadError: ArgumentError: No key representation for Tuple{String, String}. Define StructUtils.lowerkey(::Tuple{String, String})                                       
      From worker 3:    Stacktrace:                                                                                                                                                                  
      From worker 3:       [1] lowerkey(::JSON.JSONWriteStyle, x::Tuple{String, String})                                                                                                             
      From worker 3:         @ JSON ~/.julia/packages/JSON/jLnej/src/write.jl:212                                                                                                                    
      From worker 3:       [2] applyeach(st::JSON.JSONWriteStyle, f::JSON.WriteClosure{JSON.WriteOptions{JSON.JSONWriteStyle}, false, Dict{Any, Any}, IOStream}, x::Dict{Any, Any})                  
      From worker 3:         @ StructUtils ~/.julia/packages/StructUtils/CvpPP/src/StructUtils.jl:563                                                                                                
      From worker 3:       [3] json!(buf::Vector{UInt8}, pos::Int64, x::Dict{Any, Any}, opts::JSON.WriteOptions{JSON.JSONWriteStyle}, ancestor_stack::Vector{Any}, io::IOStream, ind::Int64, depth::I
nt64, bufsize::Int64)                                                                                                                                                                                
...
      From worker 2:      [39] save(io::IOStream, args::BenchmarkGroup)                                                                                                                              
      From worker 2:         @ BenchmarkTools ~/.julia/packages/BenchmarkTools/f1Vcf/src/serialization.jl:130                                                                                        
      From worker 2:      [40] #save##0                                                                                                                                                              
      From worker 2:         @ ~/.julia/packages/BenchmarkTools/f1Vcf/src/serialization.jl:109 [inlined]                                                                                             
      From worker 2:      [41] open(::BenchmarkTools.var"#save##0#save##1"{Tuple{BenchmarkGroup}}, ::String, ::Vararg{String}; kwargs::@Kwargs{})                                                    
      From worker 2:         @ Base ./io.jl:427                                                                                                                                                      
      From worker 2:      [42] open                                                                                                                                                                  
      From worker 2:         @ ./io.jl:424 [inlined]                                                                                                                                                 
      From worker 2:      [43] save(filename::String, args::BenchmarkGroup)                                                                                                                          
      From worker 2:         @ BenchmarkTools ~/.julia/packages/BenchmarkTools/f1Vcf/src/serialization.jl:108                                                                                        
      From worker 2:      [44] top-level scope                                                                                                                                                       
      From worker 2:         @ /home/nanosoldier/.julia/scratchspaces/89f34f1a-2e6b-52eb-a20f-77051b03b735/workdir/jl_1uL9lz/benchscript.jl:38                                                       

@odow
Copy link
Contributor

odow commented Oct 16, 2025

We might need to yank this version?

Would prefer that we fix this bug and released a new patch. Yanking would break stuff like this lanl-ansi/PowerModels.jl#986, where I'm updating to JSON@1, and which have BenchmarkTools in their dependency graph.

@odow
Copy link
Contributor

odow commented Oct 16, 2025

Issue seems to be

(json) pkg> st
Status `/private/tmp/json/Project.toml`
  [682c06a0] JSON v1.1.0

julia> import JSON

julia> JSON.json(Dict(("a", "b") => 1))
ERROR: ArgumentError: No key representation for Tuple{String, String}. Define StructUtils.lowerkey(::Tuple{String, String})
Stacktrace:
 [1] lowerkey(::JSON.JSONWriteStyle, x::Tuple{String, String})
   @ JSON ~/.julia/packages/JSON/jLnej/src/write.jl:212
 [2] applyeach
   @ ~/.julia/packages/StructUtils/CvpPP/src/StructUtils.jl:563 [inlined]
 [3] json!(buf::Vector{…}, pos::Int64, x::Dict{…}, opts::JSON.WriteOptions{…}, ancestor_stack::Vector{…}, io::Nothing, ind::Int64, depth::Int64, bufsize::Int64)
   @ JSON ~/.julia/packages/JSON/jLnej/src/write.jl:617
 [4] json! (repeats 3 times)
   @ ~/.julia/packages/JSON/jLnej/src/write.jl:562 [inlined]
 [5] json(x::Dict{Tuple{String, String}, Int64}; pretty::Bool, kw::@Kwargs{})
   @ JSON ~/.julia/packages/JSON/jLnej/src/write.jl:433
 [6] json(x::Dict{Tuple{String, String}, Int64})
   @ JSON ~/.julia/packages/JSON/jLnej/src/write.jl:426
 [7] top-level scope
   @ REPL[5]:1
Some type information was truncated. Use `show(err)` to see complete types.

Where previously

julia> import JSON

julia> JSON.json(Dict(("a", "b") => 1))
"{\"(\\\"a\\\", \\\"b\\\")\":1}"

@odow
Copy link
Contributor

odow commented Oct 16, 2025

Reproducer for this package is:

julia> using BenchmarkTools

julia> grp = BenchmarkTools.BenchmarkGroup();

julia> grp["a", "b"] = BenchmarkTools.BenchmarkGroup()
0-element BenchmarkTools.BenchmarkGroup:
  tags: []

julia> BenchmarkTools.save(stdout, grp)
ERROR: ArgumentError: No key representation for Tuple{String, String}. Define StructUtils.lowerkey(::Tuple{String, String})

@odow
Copy link
Contributor

odow commented Oct 16, 2025

One possible fix for BenchmarkTools is #406

@quinnj quinnj deleted the jq-json-1.0 branch October 20, 2025 23:05
@quinnj
Copy link
Contributor Author

quinnj commented Oct 20, 2025

A fix has been merged upstream in JSON to avoid breaking this pre-1.0 compat issue

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

Successfully merging this pull request may close these issues.

5 participants