Hi Mia,

On Tue, Feb 03, 2026 at 08:00:56PM +0200, Mia Kanashi wrote:
> Hiiii, replying to the archive, hopefully it works
> 
> > It could be helpful to understand why this lib needs to allocate RAM
> > when others do not.
> 
> It is due to the fact that the API is DOM based, while mjson is SAX like,
> in other words yyjson allocates structure that represents document tree,
> while mjson is just a glorified tokenizer.
> 
> It is in their plans to support StAX API, but nothing ready yet.

OK!

> See:
> 
> https://github.com/ibireme/yyjson/issues/33
> 
> https://github.com/ibireme/yyjson/issues/219

Thanks for the links.

> Note that it already supports incremental (chunked) reader with DOM:
> 
> https://github.com/ibireme/yyjson/pull/199
> 
> 
> Allocation was my concern too, they allow custom allocators though.
> StAX API would be worth looking for.
> 
> 
> Overall I just wanted to tell that that library exists,
> to integrate it if mjson parsing speed ever becomes a concern,
> integrating it right now wouldn't be productive in my opinion.

I agree, it's always interesting to know about alternate implementations.
Even if not needed right now, it could be needed later and being aware of
it would help.

> One place I think it could be useful is to provide it as an API for Lua,
> json parsing is important enough to have in the core,
> and json documents can be sometimes quite big,

Maybe but we would need to be extremely careful not to waste all CPU
cycles parsing a doc at once, otherwise during this time, other
connections are stalled and QUIC packets are lost. But still something
to keep an eye on anyway.

> but integrating it just for that isn't worth it IMO.

thanks!
Willy


Reply via email to