grafana/k6 · error
unexpected data after the JSON object
Error message
unexpected data after the JSON object
What it means
Raised by StrictJSONUnmarshal, k6's strict JSON decoding helper: after successfully decoding one JSON value there is trailing content in the input (e.g. two concatenated objects or stray tokens). It is a generic malformed-JSON guard used across options and config parsing.
Source
Thrown at lib/helpers.go:23
"encoding/json"
"fmt"
"strings"
"time"
)
// StrictJSONUnmarshal decodes a JSON in a strict manner, emitting an error if there
// are unknown fields or unexpected data
func StrictJSONUnmarshal(data []byte, v any) error {
dec := json.NewDecoder(bytes.NewReader(data))
dec.DisallowUnknownFields()
dec.UseNumber()
if err := dec.Decode(&v); err != nil {
return err
}
if dec.More() {
// TODO: use a custom error?
return fmt.Errorf("unexpected data after the JSON object")
}
return nil
}
// GetMaxPlannedVUs returns the maximum number of planned VUs at any stage of
// the execution plan.
func GetMaxPlannedVUs(steps []ExecutionStep) (result uint64) {
for _, s := range steps {
stepMaxPlannedVUs := s.PlannedVUs
if stepMaxPlannedVUs > result {
result = stepMaxPlannedVUs
}
}
return result
}
// GetMaxPossibleVUs returns the maximum number of planned + unplanned (i.e.
// initialized mid-test) VUs at any stage of the execution plan. Unplanned VUsView on GitHub (pinned to 01ffac6f24)
Solutions
- Ensure the configuration contains exactly one JSON object or array
- Remove trailing commas, duplicate objects or stray characters after the main JSON
- Validate the file with a JSON linter
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at lib/helpers.go:23 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/fac45764e044e139.
Report an issue: GitHub.