Skip to main content
added 363 characters in body
Source Link
ahm5
  • 693
  • 6
  • 11

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

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

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

added 363 characters in body
Source Link
ahm5
  • 693
  • 6
  • 11

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

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

for (key, value) in jsonDict ToStruct.tostruct( Key, key) end 

the code above would not work obviously cause Key is a String

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

added 1 character in body
Source Link
ahm5
  • 693
  • 6
  • 11

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

for (key, value) in jsonDict ToStruct.tostruct( Key, key) end 

the code above would not work obviously case thecause Key is a String

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

for (key, value) in jsonDict ToStruct.tostruct( Key, key) end 

the code above would not work obviously case the Key is a String

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

for (key, value) in jsonDict ToStruct.tostruct( Key, key) end 

the code above would not work obviously cause Key is a String

Source Link
ahm5
  • 693
  • 6
  • 11
Loading