With your code Unmarshal is looking for l.a at the top level in the JSON (and it's not there - x is).
There are a number of ways you can fix this, the best is going to depend upon your end goal; here are a couple of them (playground)
const jsonTest = `{"x":{"l.a":"test"}}`
type Object struct {
Foo map[string]string `json:"x"`
}
func main() {
var obj Object
err := json.Unmarshal([]byte(jsonTest), &obj)
if err != nil {
fmt.Println(err)
}
fmt.Println("jsonObj", obj)
var full map[string]map[string]string
err = json.Unmarshal([]byte(jsonTest), &full)
if err != nil {
fmt.Println(err)
}
fmt.Println("jsonObj2", full)
}
(Got a phone call while entering this and see @DavidLilue has provided a similar comment but may as well post this).
Footo look into thel.aproperty but that property is not present in the root object. Maybe your intention is to havejson:"x"as the tag. Also,map[string]map[string]stringis redundant,Objectacts like the root object so you would need justmap[string]string.