2018-06-22 20:57:24 +00:00
|
|
|
# Pkg.add("JSON") ... an external library http://docs.julialang.org/en/latest/packages/packagelist/
|
|
|
|
|
using JSON
|
2014-01-17 05:32:22 +00:00
|
|
|
|
2018-06-22 20:57:24 +00:00
|
|
|
sample = Dict()
|
|
|
|
|
sample["blue"] = [1, 2]
|
|
|
|
|
sample["ocean"] = "water"
|
2014-01-17 05:32:22 +00:00
|
|
|
|
2018-06-22 20:57:24 +00:00
|
|
|
@show sample jsonstring = json(sample)
|
|
|
|
|
@show jsonobj = JSON.parse(jsonstring)
|
|
|
|
|
|
|
|
|
|
@assert jsonstring == "{\"ocean\":\"water\",\"blue\":[1,2]}"
|
|
|
|
|
@assert jsonobj == Dict("ocean" => "water", "blue" => [1, 2])
|
|
|
|
|
@assert typeof(jsonobj) == Dict{String, Any}
|