I am quite new to Julia and struggling with quite simple task.
mutable struct XYZ
id::Int64
item::JSON3.Object
end
To that structure I am trying to add default/empty constructor (setting item to empty JSON3.Object):
XYZ()=XYZ(0, {})
That gives me an error:
ERROR: LoadError: LoadError: syntax: { } vector syntax is discontinued around myfile.jl line n
I could work around it this way:
str="""{}"""
emptyJson=JSON3.read(str)
XYZ()=XYZ(0, emptyJson)
but that seems quite ugly to me. Moreover, line
emptyJson=JSON3.read(str)
prints {} in the output, so I should be able to use XYZ()=XYZ(0, {}).
I don’t understand why it doesn’t work and what would be the best code for what I am trying to achieve.
Thank you.
4 posts - 2 participants