I'm trying to interpret JSONs in Golang. I'm searching for a specific attribute in an unknown JSON which I know the keys for but my JSON might be really nested. I do know how many 'layers' there are in my JSON.
For example, if my JSON is:
nestedJson = { key1: { key2: { key3: "Found data" } } }
my keys are ["key1", "key2", "key3"] and there are 3 layers in this JSON so I can get the data back out by doing
var nestedJson = []map[string]map[string]map[string]interface{}
json.Unmarshal([]byte(nestedJon), &nestedJson)
data := nestedJson["key1]["key2"]["key3"]
What I want to be able to do is dynamically create that nestedJson object by specifying an integer value for the number of layers is should search through.
Can anyone help with this? Please let me know if I haven't been clear enough!