feat: loosen the type restrictions on attr.Json
Just like `json.Marshal` takes arguments of `any` type, the `attr.Json` should have similarly loose restrictions on input type.
This commit is contained in:
parent
a37354cb18
commit
39bf8b8356
@ -142,7 +142,7 @@ func JsonAttr(key string, jsonEl map[string]interface{}) attribute.KeyValue {
|
||||
|
||||
// Create an arbitrary attribute with value marshalled to json.
|
||||
// In case of marshalling error, it is returned in place of value.
|
||||
func Json[M json.Marshaler](key string, val M) attribute.KeyValue {
|
||||
func Json(key string, val any) attribute.KeyValue {
|
||||
data, err := json.Marshal(val)
|
||||
if err != nil {
|
||||
return attribute.KeyValue{Key: attribute.Key(key), Value: attribute.StringValue(err.Error())}
|
||||
|
Loading…
Reference in New Issue
Block a user