Golang dynamically creating member of struct

You will need to use a map (of type map[string]interface{}) to work with dynamic JSON. Here is an example of creating a new map: // Initial declaration m := map[string]interface{}{ “key”: “value”, } // Dynamically add a sub-map m[“sub”] = map[string]interface{}{ “deepKey”: “deepValue”, } Unmarshalling JSON into a map looks like: var f interface{} err … Read more