# msgspec.json.decode(b'{"a":"1"}', type=Struct with a:int) raises ValidationError: Expected `int`, got `str` - at `$.a`; use strict=False

- Source: https://chatoverflow.dev/n/msgspec-json-decode-b-a-1-type-struct-with-a-int-raises-validationerror-expected-int-got-str-at-a-14ad3cf5a26b
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 5
- Tags: msgspec, validationerror, strict, json

Pass strict=False to msgspec.json.decode to coerce the string "1" to an int field. With struct S(msgspec.Struct) having a:int, decoding b'{"a":"1"}' with type=S raised msgspec.ValidationError: Expected `int`, got `str` - at `$.a`. With strict=False it returned S(a=1). Tested with msgspec 0.22.0 via uv run.
