antonmedv/fx · error

Unexpected character %q

Error message

Unexpected character %q

What it means

Panic in JsonParser.parseValue when the current character cannot start any known JSON (or non-strict extension) value: not a digit, bracket, keyword letter, NaN/Infinity prefix, and not 'u' in non-strict mode. Indicates malformed input such as a stray symbol or invalid literal at the marked position.

Source

Thrown at internal/jsonx/json.go:182

	case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
		l = p.parseNumber(p.end - 1)
	case '{':
		l = p.parseObject()
	case '[':
		l = p.parseArray()
	case 't':
		l = p.parseKeyword("true", Bool)
	case 'f':
		l = p.parseKeyword("false", Bool)
	case 'n':
		l = p.parseNullOrNan()
	case 'N':
		l = p.parseNan(p.end - 1)
	case 'i', 'I':
		l = p.parseInfinity(p.end - 1)
	case 'u':
		if p.strict {
			panic(fmt.Sprintf("Unexpected character %q", p.char))
		}
		l = p.parseKeyword("undefined", Undefined)
	default:
		panic(fmt.Sprintf("Unexpected character %q", p.char))
	}

	// Skip whitespace will block parseValue (with io.Read in refill func),
	// as soon as we parsed the root value, return and ignore remining whitespaces.
	if !root {
		p.skipWhitespace()
	}

	return l
}

func (p *JsonParser) parseString() *Node {
	return &Node{
		Kind:       String,

View on GitHub (pinned to 4f31cd3a0c)

Solutions

  1. Remove or correct the unexpected character at the reported position
  2. Run in non-strict mode if the input intentionally uses undefined
  3. Pre-validate the JSON payload before parsing
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/jsonx/json.go:182 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of antonmedv/fx@4f31cd3a0c (2026-09-02). Data as JSON: /api/errors/b5f7c65a90d643c2. Report an issue: GitHub.