Hi,
I am loading a json file (see specimen below) into a generic interface{} object and I want to convert it into a formal struct. My problem is that the ‘properties’ → ‘help’ → ‘properties’ arrays repeat until the child ‘help’ array is NULL, which we don’t know in advance.
{
"list": {
"lstexampleA": [
{ "properties": [
{
"with": "OPTION1",
"help": [
{
"properties": [
{
"with": null,
"help": null,
"element": "MP0001"
}
]
},
{
"properties": [
{
"with": null,
"help": null,
"element": "MP0002"
}
]
}
]
},
{
"with": "OPTION6",
"help": null,
"element": 10
}
],
"element": 100
}
],
"lstexampleB": [ .....
]
}
}
So something like this perhaps…
var olists []oList
type oList struct {
OWith string
OHelp []oList
OElement interface{}
}
Is there a standard way to traverse the interface{} object, building up the struct as we go…
Thanks
Steffi