News for hackers. Stuff that matters.
Re:Progressive JSON by vinnymac on Saturday May 31, 2025 @11:11PM (#44148426)
I already use streaming partial json responses (progressive json) with AI tool calls in production.

It’s become a thing, even beyond RSCs, and has many practical uses if you stare at the client and server long enough.

Re:Progressive JSON by tough on Sunday June 01, 2025 @12:21AM (#44148644)
how do you do that exactly?
Re:Progressive JSON by richin13 on Sunday June 01, 2025 @08:42AM (#44150459)
Not the original commenter but I’ve done this too with Pydantic AI (actually the library does it for you). See “Streaming Structured Output” here https://ai.pydantic.dev/output/#streaming-structured-output
Re:Progressive JSON by tough on Sunday June 01, 2025 @02:13PM (#44152740)
Thanks yes! Im aware of structured outputs, llama.cpp has also great support with GBNF and several languages beyond json.

I've been trying to create go/rust ones but its way harder than just json due to all the context/state they carry over

Re:Progressive JSON by danenania on Sunday June 01, 2025 @02:11PM (#44152728)
One way is to eagerly call JSON.parse as fragments are coming in. If you also split on json semantic boundaries like quotes/closing braces/closing brackets, you can detect valid objects and start processing them while the stream continues.
Re:Progressive JSON by tough on Sunday June 01, 2025 @02:16PM (#44152755)
Interesting approach! thanks for sharing
Re:Progressive JSON by motorest on Sunday June 01, 2025 @02:51AM (#44149092)
Can you offer some detail into why you find this approach useful?

From an outsider's perspective, if you're sending around JSON documents so big that it takes so long to parse them to the point reordering the content has any measurable impact on performance, this sounds an awful lot like you are batching too much data when you should be progressively fetching child resources in separate requests, or even implementing some sort of pagination.

Re:Progressive JSON by Wazako on Sunday June 01, 2025 @08:32AM (#44150408)
Slow llm generation. A progressive display of a progressive json is mandatory.