News for hackers. Stuff that matters.
Re:JSON Schema by willtim on Sunday February 18, 2018 @03:30PM (#16408321)
It's such a shame that many of these standards ignore or are ignorant of the elementary and fundamental sum type. Instead I am left needing to employ some ad-hoc encoding using string tags or similar.
Re:JSON Schema by deathanatos on Sunday February 18, 2018 @06:09PM (#16409440)
I agree wholeheartedly (I have so many use cases for a sum type!), but I think that opportunity was lost when JSON itself was created; JSON-schema, built on top of JSON, would have to make some assumptions about how to map any sum type onto JSON, since JSON doesn't natively support them. JSON-schema — reasonably, I think — doesn't.
Re:JSON Schema by dmcg on Sunday February 18, 2018 @04:45PM (#16408912)
Does oneOf not cover it?
Re:JSON Schema by willtim on Sunday February 18, 2018 @05:56PM (#16409354)
oneOf looks like it could be used to encode sum types together with a custom string tag, but that's not the first class treatment that records get.
Re:JSON Schema by henryluo on Saturday March 03, 2018 @11:20AM (#16509933)
Mark (https://mark.js.org) is a new notation that extends JSON with a type-name, which can be a more structured way to encode type info, instead of using custom string tag.