I want to dynamically define structs in a Go project based on a JSON file.
For example, if I had a json file like so...
{
"date": "today",
"time": 12,
"era": "never",
"alive": true
}
Then I would expect a struct to be generated (that would look) like this (but not explicitly defined in the source code)...
type DynamicJSON struct {
date, era string
time int
alive bool
}
Furthermore, I want to nest JSON objects such that I could do something like this...
{
"date": "today",
"time": 12,
"era": "never",
"alive": true,
"nested": {
"date": "tomorrow",
"alive": true
}
}
...which would actually generate two different structs, like this...
type DynamicJSON1 struct {
date, era string
time int
alive bool
}
type DynamicJSON2 struct {
date string
alive bool
}
Is this something that is currently supported?
map[string]interface{}