Repository navigation
Conversation
`Union{}` is a subtype of every type, so `Vector{Union{}}` matched the
`arraylike(::JSONStyle, ::AbstractVector{<:Pair}) = false` method and
empty vectors with element type `Union{}` (e.g. JSON3.jl's empty arrays)
were written as JSON objects. Add a more specific `arraylike` method
for `AbstractVector{Union{}}` returning `true`.
Fixes JuliaIO#499
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #500 +/- ##
=======================================
Coverage 92.57% 92.58%
=======================================
Files 7 7
Lines 1927 1928 +1
=======================================
+ Hits 1784 1785 +1
Misses 143 143 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Self-review notes (now rebased: this PR is the minimal
Locally all testsets pass; the trailing segfault in the juliac |
The motivating case is JSON3.Array{Union{}}, which is not a Vector, so
pin the AbstractVector breadth of the arraylike method.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
12766ae to
1e8834e
Compare
Fixes #499.
Union{}is a subtype of every type, soVector{Union{}} <: AbstractVector{<:Pair}holds and empty vectors with element typeUnion{}dispatched toand were written as JSON objects. This shows up in practice for values parsed by JSON3.jl, which types every empty array as
JSON3.Array{Union{}, …}, so a JSON3 → JSON.jl round trip turned[]into{}.This adds a more specific method:
Before / after:
Existing
Vector{Pair}→ object behaviour is unchanged. Added regression tests intest/json.jl.🤖 Generated with Claude Code