DataArrays.jl
DataArrays.jl copied to clipboard
Cannot JSON convert data arrays with NA
cannot JSON convert any data arrays with NA.
JSON.json(@data [1,2,NA]) used to produce "[1,2,{}]" but now produces the error "Cannot serialize type DataArrays.NAtype"
guessing this is because the vector syntax {} is now discontinued
is there a workaround? or before converting do we have to manually convert all data arrays to nothing or "" ?
This issue was reported in JSON.jl.
Hmm, serialization seems to work fine, so I'm not sure what's the problem. Will ask upstream.
using DataArrays
x=@data [1,2,NA]
io=IOBuffer()
serialize(io, x)
seekstart(io)
deserialize(io)
As a workaround you can just write
try JSON.lower(NA) catch
JSON.lower(::DataArrays.NAtype) = nothing
end
in your own code for now. This is type piracy and not a good long term solution, but the try/catch ensures that it will only add the definition if it doesn't already exist.
A slightly nicer (though basically equivalent) workaround:
if !applicable(JSON.lower, NA)
JSON.lower(::NAtype) = nothing
end