I have Dict and all keys in that Dict have their own Types with the same name, so I need to get the Key but not as String, as Type.
toStruct function get two parameters, the first is the Type (in my case is the same as the Key) and the second is the Dict
julia> jsonDict
Dict{String, Any} with 2 entries:
"TypeExample1" => Dict{String, Any}("attr" => 5)
"TypeExample2" => Dict{String, Any}("attr" => 10)
struct TypeExample1
attr
end
struct TypeExample2
attr
end
for (key, value) in jsonDict
ToStruct.tostruct( Key, key)
end
the code above would not work obviously cause Key is a String the output should be 2 structs (TypeExample1,TypeExample2) with the assigned values
PS: it would work like this:
ToStruct.tostruct( TypeExample1, jsonDict["TypeExample1"])
but I need to automate this process