Hacker News new | ask | show | jobs
by nivertech 1997 days ago
IMO it's better to use JSONL[1].

Also back in the day IBM had XML for Logging format, where every separate line was an XML fragment [2].

Most markup languages suffering of having a root element, which prevents efficient logging or steaming.

[1] https://jsonlines.org/

[2] https://en.wikipedia.org/wiki/XML_log

1 comments

JSONL is often better if you can spec that from scratch, but, sadly, still has somewhat poor support in a lot of environments that support JSON. I've had the most problem with interacting with people using environments that are "helpful" and aren't really programming languages, and I usually end up having to offer them a plain array anyhow.

This can also be helpful when you're outputting, say, a 10MB JSON object, which isn't necessarily that large anymore, on a server where you'd like to not have to allocate 10MB of RAM to it. You can stream out a plain ol' JSON object without the resource usage.

Sadly, it is indeed easier to convince environments to stream JSON out than it is to stream it in.