TSON – A JSON superset with immutable, hash-pinned schemas
Posted by andrewjneumann 1 day ago
Comments
Comment by kbolino 1 day ago
Comment by sakjur 17 hours ago
!!schema: { url: "https://example.com/people.tn" sha256: "c4d5e6f7…a2b3c4d5" }Comment by geoah 1 day ago
Comment by thyristan 1 day ago
Comment by kbolino 1 day ago
Comment by thyristan 1 day ago
Comment by kbolino 17 hours ago
* = Including urllib.parse (Python), url_parse (PHP), java.net.URI (Java), System.Uri (.NET), net/url.URL (Go), curl_url_get (libcurl), URL (JavaScript, which calls it the "hash"), url::Url (Rust), Boost.URL (C++)
Comment by thyristan 1 day ago
No comments means that one cannot use it for configuration. Properties repeat the XML mistake of the attribute/content dichotomy.
And trailing commas as a syntax error prevents easy sorting/appending/editing of arrays.
And it doesn't fix a ton of JSON problems like strings containing newlines, quotes and the like, while introducing a ton of new problems, like the dependency on obscure Unicode features to elide quotes. This will lead to TSON homoglyph attacks.
Comment by Retr0id 1 day ago
Also, I see mention of hashing, but no mention of canonicalization. Does fiddling with a schema's whitespace change its hash?
Comment by ramses0 1 day ago
$ echo '{ "Hello": "World" }' | tson --parse
ERROR: ...refusing to interoperate w/ JSON b/c we want to be different
...that's a non-starter. If they're trying to replace or supplement JSON (same way `uv` has been replacing / supplementing `pip`, and `deno` is doing the same with `node`), you've got to do the work of supporting the extant real-world use cases that are floating around but with a healthy layer of $BETTER sprinkled on top. $ echo '{ "Hello": !number 3.14 }' | jq '.'
jq: parse error: Invalid numeric literal at line 1, column 19
...THAT's the difference/extension.I've been explicitly trying to support `--json5` on some of my internal work tooling. Being very explicit that I'm not parsing `--json`, but instead using a slower (but more forgiving) `--json5` which would allow comments, trailing commas, whatever JSON5 claims to support.
This `--tson` feels like it's solving two problems in disguise:
1) It wants to be `--json6` (eg: `pi: !number 3.14`)
2) It wants to use it's own `--json6` (aka: `--tson`) to write "json-ish schemas" (eg: `foo: [text; 1..10]` for presumably a list of maximum of 10 elements?)
...JSON was a blessing because it existed naturally as an unambiguous "lists, dicts, values" representation that most programming languages treat as first-class citizens. Missing "sets" and things like "date" or "boolean" are certainly under-specified, but that's the real-world impact of JSON as lowest common denominator.
SCHEMA's don't have nearly as much natural, unambiguous representations across many programming languages. The closest thing I can think of is straight up Java + Constructors (ie: a full programming language for object initialization but w/o allowing interaction or behavior).
CalendarEvent x = new CalendarEvent( Date start, Date end, Boolean all_day, List<Invitee<...>>, ...etc... )
...where my mind has gone lately is doubling down on TypeScript's `*.d.ts` as a "naturally occurring, expressive schema language". It's hella-more-complicated to parse/validate than JSON, but there's tons of tooling around it, and it's relatively unambiguous that it can solve and express Real World(tm) engineering problems.Comment by deepsun 1 day ago
But it's pretty ambiguous when parsing. Like a long number -- is it a floating point, BigInt or i128? Every language is different
JSON was a blessing because it was literally Javascript. It was unambiguous in Javascript only.
A true unambiguous would be "everything is a string", like TCL.
Comment by Retr0id 1 day ago
Comment by gwbas1c 1 day ago
> Data with an immutable schema.
> TSON (Typed Schema Object Notation) is a schema system with immutable, hash-pinned schemas whose definitions are themselves data. A document names its schema, the schema names its meta-schema; one hash verifies the whole chain. The finishing touch, TSON's data format is a Unicode-first superset of JSON you'll actually enjoy writing.
I'm not sure what problem this is solving?
I rarely have issues with JSON schema validation; and when I do, the failure patterns aren't something that I want to offload to a 3rd party library.
Basically, how my application fails with poorly formed JSON is part of how I define my application, which means that unexpected JSON needs to be handled on a case-by-case basis.
---
Anyway, the system smells like xsd, which when I used it, wasn't worth the effort.
Comment by hmokiguess 1 day ago
Comment by yourapostasy 1 day ago
So I've never rejected XML out of hand, but I've always been "show me" skeptical of calls for it and pushed for explanations on why the business requirements feel the justification to adopt XML. Sometimes I've seen it totally makes sense, but with the conceptual rigor it requires in those use cases, the skillset and expertise of the development team has to reach a higher than average bar. I'm cautiously hopeful LLM's might help with lowering that bar, but time will tell.
Comment by conartist6 1 day ago
If you want to know how I would approach designinga language to fill XML's market niche, check out https://docs.bablr.org/guides/cstml
Comment by pyuser583 1 day ago
Comment by minraws 1 day ago
Comment by kelseydh 1 day ago
Comment by al_be_back 1 day ago
Of course, immutable means as-is, but since you're not dealing with ordering etc (that's pretty big), I might as well use existing tech (JSON with a schema) and a policy (simple/naive: hash and compare lowercased data).
[1] From their spec: 2.2.1 Identity and Content Addressing - https://tson.io/2026/32/tson-part1-data/#
Comment by lokar 1 day ago
Comment by pratyahava 1 day ago
Comment by lokar 1 day ago
I’ve used it once for something small. It was ok, but the docs and some of the libraries were a bit lacking.
But it demonstrates the kind of things you could have if you don’t care about text/parser compatibility with json
Comment by azatom 1 day ago
Comment by robto 1 day ago
Don't know how I feel about optional quotes around strings, that seems like a mistake. And having an immutable set literal would be nice as well.
Comment by waweic 1 day ago
Really unfortunate naming
Comment by eventualcomp 1 day ago
Given also that it's a big tech technology I am going to wager that it's not going away anytime soon.
Comment by jensneuse 1 day ago
Comment by Yannik_Sc 1 day ago
> Data with an immutable schema.
But for what? I don't see a fit for APIs here, maybe config but there are already other languages that are perfectly suited for this job.
Also this feels more like some proposal than a serious attempt to build a new format. Java is widely used but I would at least expect such a new format to at least release with Java-/TypeScript, Go and Python libraries (personal perference: Rust too). But just a Java launch is at best a PoC.
Comment by tomnipotent 1 day ago
Baically protobuf, Cap’n Proto, msgpack, Avro, or every other serialization approach that versions schemas?
Comment by corbindavenport 1 day ago
Comment by aggregator-ios 1 day ago
Comment by polymer8563 19 hours ago
Comment by aljarry 1 day ago
Comment by polymer8563 19 hours ago
Comment by myshapeprotocol 1 day ago
Comment by andrewjneumann 1 day ago
Comment by hdjrudni 1 day ago
I don't understand how this helps. That just means I have dozens of schemas for the same data set. How is that better? I'd rather have one lowest common denominator schema for the entire data set and be forced to validate.
I mean I guess because the data blob specifies its own schema I can use that schema to ensure the blob is valid but then what. What is my code that processes this data supposed to do? `if(schema1) { ... } else if(schema2) { ... }`. How is that better?
Comment by sandeepkd 1 day ago
Comment by tonyg 1 day ago
Comment by eska 1 day ago
Comment by flanked-evergl 1 day ago
Comment by IncreasePosts 1 day ago
How do you add schema info to that?
Comment by crote 1 day ago
{
'schema': 'c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2',
'data': []
}Comment by phailhaus 1 day ago
Comment by ltbarcly3 1 day ago
Comment by hyperhello 1 day ago
Comment by inigyou 1 day ago
Comment by IncreasePosts 1 day ago
Comment by inigyou 1 day ago
Comment by phailhaus 13 hours ago
If you are passing around lists of structured objects, I need you to send me what those objects are supposed to look like even if the list is empty sometimes. If you say "ok so sometimes I'll give you an object with a schema key and a list of data, other times I will just give you an empty list because I don't feel like it", everyone will hate you.
Comment by ltbarcly3 1 hour ago
Comment by tanepiper 1 day ago
Comment by esafak 1 day ago
Comment by tantalor 1 day ago
Comment by hdjrudni 1 day ago
> Protobuf even marks the required keyword a hazard developers must avoid. These rules exist because a single definition is forced to serve every document ever written against it. TSON removes this burden because schemas are immutable.
I personally don't have a problem with them. They've grown on me. Thought they looked icky before I actually had to use them. Now I see their merit.
Comment by kkukshtel 1 day ago
Comment by dizlexic 1 day ago
Comment by biggestlou 1 day ago
Comment by ltbarcly3 1 day ago
Comment by thomasnowhere 1 day ago