Reading Python datastructure (from text file) in Julia

I suppose if your vim magic can find all those array with ill-format number and encode the whole thing into a string, then you don’t have to mess around with internal of a JSON parser.

julia> raw_string = """
       [
       {
       "origin": "Jupiter",
       "data_x": [1.0, 2.0, 3.0],
       "data_phi": "[2+3j, 3-1j, 1.2-3.4j]"
       }]
       """
"[\n{\n\"origin\": \"Jupiter\",\n\"data_x\": [1.0, 2.0, 3.0],\n\"data_phi\": \"[2+3j, 3-1j, 1.2-3.4j]\"\n}]\n"

julia> using JSON

julia> d = JSON.Parser.parse(raw_string)
1-element Vector{Any}:
 Dict{String, Any}("data_x" => Any[1.0, 2.0, 3.0], "data_phi" => "[2+3j, 3-1j, 1.2-3.4j]", "origin" => "Jupiter")

julia> const j =im
im

julia> first(d)["data_phi"] |> x->eval(Meta.parse(x))
3-element Vector{ComplexF64}:
 2.0 + 3.0im
 3.0 - 1.0im
 1.2 - 3.4im
2 Likes