This does not work: // MarshalJSON implements json.Marshaler interface func (j *JsonObject) MarshalJSON() ([]byte, error) { if !j.Valid { return []byte("null"), nil } if j.HasTopLevelArray() { return json.Marshal(j.StringAnyMap[topLevelArrayKey]) } return json.Marshal(j.StringAnyMap) } This does: // MarshalJSON implements json.Marshaler interface func (j JsonObject) MarshalJSON() ([]byte, error) { if !j.Valid { return []byte("null"), nil } if j.HasTopLevelArray() { return json.Marshal(j.StringAnyMap[topLevelArrayKey]) } return json.Marshal(j.StringAnyMap) } This piece of code has been enhanced and is now part of the ground project. But this was a not-so-pleasant surprise!