Skip to content

Commit

Permalink
indicate invalid slice if we couldn't turn them into json
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Apr 30, 2024
1 parent c7ef823 commit 565c87f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions attribute/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,26 @@ func (v Value) Emit() string {
case BOOL:
return strconv.FormatBool(v.AsBool())
case INT64SLICE:
j, _ := json.Marshal(v.asInt64Slice())
j, err := json.Marshal(v.asInt64Slice())
if err != nil {
return fmt.Sprintf("invalid: %v", v.asInt64Slice())
}
return string(j)
case INT64:
return strconv.FormatInt(v.AsInt64(), 10)
case FLOAT64SLICE:
j, _ := json.Marshal(v.asFloat64Slice())
j, err := json.Marshal(v.asFloat64Slice())
if err != nil {
return fmt.Sprintf("invalid: %v", v.asFloat64Slice())
}
return string(j)
case FLOAT64:
return fmt.Sprint(v.AsFloat64())
case STRINGSLICE:
j, _ := json.Marshal(v.asStringSlice())
j, err := json.Marshal(v.asStringSlice())
if err != nil {
return fmt.Sprintf("invalid: %v", v.asStringSlice())
}
return string(j)
case STRING:
return v.stringly
Expand Down

0 comments on commit 565c87f

Please sign in to comment.