← Back to context

Comment by kstenerud

3 hours ago

This is great! The more human-readable, the better!

I've also been working in the other direction, making JSON more machine-readable:

https://github.com/kstenerud/bonjson/

It has EXACTLY the same capabilities and limitations as JSON, so it works as a drop-in replacement that's 35x faster for a machine to read and write.

No extra types. No extra features. Anything JSON can do, it can do. Anything JSON can't do, it can't do.

This is very interesting, though the limitations for 'security' reasons seem somewhat surprising to me compared to the claim "Anything JSON can do, it can do. Anything JSON can't do, it can't do.".

Simplest example, "a\u0000b" is a perfectly valid and in-bounds JSON string that valid JSON data sets may have in it. Doesn't it end up falling short of 'Anything JSON can do, it can do" to refuse to serialize that string?

Can you tell me what was the context that lead you to create this?

Unrelated JSON experience:

I worked on a serializer which save/load json files as well as binary file (using a common interface).

From my own use case I found JSON to be restrictive for no benefit (because I don't use it in a Javascript ecosystem)

So I change the json format into something way more lax (optional comma, optional colon, optional quotes, multi line string, comments).

I wish we would stop pretending JSON to be a good human-readable format outside of where it make sense and we would have a standard alternative for those non-json-centric case.

I know a lot of format already exists but none really took off so far.

  • Basically, for better or worse JSON is here to stay. It exists in all standard libraries. Swift's codec system revolves around it (it only handles types that are compatible with JSON).

    It sucks, but we're stuck with JSON. So the idea here is to make it suck a little less by stopping all this insane text processing for data that never ever meets a human directly.

    The progression I envisage is:

    1. Dev reaches for JSON because it's easy and ubiquitous.

    2. Dev switches to BONJSON because it's more efficient and requires no changes to their code other than changing the codec library.

    3. Dev switches to a sane format after the complexity of their app reaches a certain level where a substantial code change is warranted.

That's neat, but I'm much more intrigued by your Concise Encoding project[1]. I see that it only has a single Go reference implementation that hasn't been updated in 3 years. Is the project still relevant?

Thanks for sharing your work!

[1]: https://concise-encoding.org/

  • Thanks!

    I'm actually having second thoughts with Concise Encoding. It's gotten very big with all the features it has, which makes it less likely to be adopted (people don't like new things).

    I've been toying around with a less ambitious format called ORB: https://github.com/kstenerud/orb

    It's essentially an extension of BONJSON (so it can read BONJSON documents natively) that adds extra types and features.

    I'm still trying to decide what types will actually be of use in the real world... CE's graph type is cool, but if nobody uses it...