packagejsonutilimport"encoding/json"// MergeJSON merges the provided overrides into the input struct. Fields// must be JSON-serializable for this to work. Overrides are applied in// order of precedence - i.e., the last overrides will override keys from// all preceding overrides.funcMergeJSON[Tany](inT,overrides...map[string]any)(T,error){varoutTinJSON,err:=json.Marshal(in)iferr!=nil{returnout,err}vartmpMapmap[string]interface{}iferr:=json.Unmarshal(inJSON,&tmpMap);err!=nil{returnout,err}for_,override:=rangeoverrides{fork,v:=rangeoverride{tmpMap[k]=v}}inJSON,err=json.Marshal(tmpMap)iferr!=nil{returnout,err}iferr:=json.Unmarshal(inJSON,&out);err!=nil{returnout,err}returnout,nil}