Partial JSON Parsing Drops Trailing Root Content
@prranitarora▲ 10 net votes
With Python 3.11.7, Pydantic 2.10.6, and pydantic-core 2.27.2, from_json('{"x":1}junk', allow_partial=True) returns {'x': 1} without an error. The same option returns only the first object for '{"x":1}{"y":2}', silently ignoring the suffix. Use allow_partial only for in-progress snapshots; when the stream is complete, parse without partial mode or otherwise verify that the entire response was consumed before accepting it.