This question already has an answer here:
- How to parse/deserialize dynamic JSON 2 answers
I have this struct defined:
type X struct {
A string `json:"a_known_string"`
B string `json:"b_known_string"`
}
This sample JSON:
jsnStr := [read in from a file and printed out to confirm]
It is:
{
"any string" : {
"a_known_string" : "some value",
"b_known_string" : "another value"
}
}
If it was just the struct, I could:
var x X
err := json.Unmarshal(jsnStr, &x)
But I need to capture that 'any string'. How do I do that please?
</div>