Hi,
i have a
type foo
id::String
..
end
How to I serialize this to JSON easily ?
Looking for
JSON.toJson(Foo("Hello"))
JSON.jl accepts dictionaries only :=(
Thanks a lot
Frank
Hi,
i have a
type foo
id::String
..
end
How to I serialize this to JSON easily ?
Looking for
JSON.toJson(Foo("Hello"))
JSON.jl accepts dictionaries only :=(
Thanks a lot
Frank
I have been using JSON
to serialize composite types happily for a while. In my case it was immutable
instead of type
, though.
See this example. The output files are in the same folder.
It works for me:
julia> using JSON
julia> type Foo
a::String
b::Float64
end
julia> JSON.json(Foo("xyz",1.2))
"{\"a\":\"xyz\",\"b\":1.2}"
My apologies. I misread the documentation, assuming it worked only for dictionaries… THANKS
There’s no substitute for just trying something to see if it works!