I have a question similar to this one:

https://groups.google.com/forum/?hl=en#!topic/julia-users/Q2vZEpDdV44

I've been hanging around here for a while, but still just getting my feet 
wet building things in Julia. One thing I needed was to be able to parse 
some matrices in JSON. The result I get from JSON.parse is naturally a 
Vector{Any}, where each element is another Vector{Any}, but I want 
Matrix{Float64}, so I hesitantly did this:

import Base.convert

function convert(::Type{Matrix{Float64}},a::Array{Any,1})
  nrow = length(a)
  ncol = length(a[1])
  mat = zeros(nrow,ncol)
  for i=1:nrow
    mat[i,:] = convert(Vector{Float64},a[i])
  end
  return mat
end


Is there a better way?

Row major vs column major issues 
<https://github.com/JuliaLang/JSON.jl/issues/93> aside :)

Reply via email to