Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions types/stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,18 @@ func (es *EventStream[T]) Next() bool {
}
encoding, _ = et.GetEventEncoding(ev)
} else {
var a interface{}
if err := json.Unmarshal([]byte(data), &a); err != nil {
if !json.Valid([]byte(data)) {
encoding = "string"
}
}

// "auto" means the data field is a mixed union (JSON + plain-text variants).
// Probe the actual data to decide.
if encoding == "auto" {
var a interface{}
if err := json.Unmarshal([]byte(data), &a); err != nil {
encoding = "string"
} else {
if json.Valid([]byte(data)) {
encoding = "application/json"
} else {
encoding = "string"
}
}

Expand Down