Skip to content

Commit

Permalink
Fix show_json(A::AbstractArray{T,0}) (#184)
Browse files Browse the repository at this point in the history
Writes the first element of A.
  • Loading branch information
alyst authored and TotalVerb committed May 5, 2017
1 parent 318657b commit f28c6e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ function show_json{T,n}(io::SC, s::CS, A::AbstractArray{T,n})
end_array(io)
end

# special case for 0-dimensional arrays
show_json{T}(io::SC, s::CS, A::AbstractArray{T,0}) = show_json(io, s, A[])

show_json(io::SC, s::CS, a) = show_json(io, s, lower(a))

# Fallback show_json for non-SC types
Expand Down
3 changes: 3 additions & 0 deletions test/serializer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,7 @@ let filename = tempname()
rm(filename)
end

# issue #184: serializing a 0-dimensional array
@test sprint(JSON.show_json, JSON.StandardSerialization(), view([184], 1)) == "184"

end

0 comments on commit f28c6e7

Please sign in to comment.