Files
Piik/internal/client/nativecapture/json.go
T
AAA da47189fc3 refactor: unify Go runtime and audited frontend
Squash integration of the reviewed Go core, frontend audit fixes, release tooling, and deployment hygiene. CI passed all Server/Client jobs.
2026-09-06 23:26:01 +08:00

21 lines
409 B
Go

package nativecapture
import (
"bytes"
"encoding/json"
"errors"
"io"
)
func decodeStrictJSON(payload []byte, value any) error {
decoder := json.NewDecoder(bytes.NewReader(payload))
decoder.DisallowUnknownFields()
if err := decoder.Decode(value); err != nil {
return err
}
if err := decoder.Decode(&struct{}{}); !errors.Is(err, io.EOF) {
return errors.New("trailing JSON data")
}
return nil
}