Live data from Hacker News

Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees

news.ycombinator.com

41–50 of 179 posts

Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees

#41
I'm not currently using it, but I'm strongly considering validating json in postgres with https://github.com/supabase/pg_jsonschema - which uses the https://docs.rs/jsonschema/latest/jsonschema/ Rust crate

So I'm not sure if my feedback is valid but, I sure hope that the jsonschema crate follows the spec! Otherwise I'll never use jsonschema but instead something-not-exactly-jsonschema. In other words.. you better not break anything.

Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees

#43

This gives you a pretty good feel for where it’s at: https://json-schema.org/blog/posts/future-of-json-schema I’m invested in it. I’m using it to provide implementation-specific validation of requests to/from a third party API. I wish there was a good macOS editor or IDEA plugin for it with autocomplete etc. The static generators from examples are obscure, ugly, minimal, and can’t account for variations. It isn’t ple…

Have you looked at vscode? It supposedly supports json schema (https://code.visualstudio.com/docs/languages/json) and I’ve been thinking about trying it out.

Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees

#44

I use JSONschema, it's honestly great the way it is [0]. So I guess the guarantee I want is "don't change anything"? Ha. [0] my biggest gripe is it's not well defined what to do with multipleOf when the number isn't an exact integer.

Your [0] might be a change that can be made in a backwards compatible manner.. as long as current implementations don't diverge on what they do when the number is not an integer (whether they error or do something)

Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees

#45
post #36

JSON Schema is awesome. I wish Typescript had better support for it though, having to do stuff in Zod and JSON Scheme sucks. I have a system I built that compiles TS types to JSON schema, which then validates data coming into my endpoints, this way I am typesafe at compile time (Typescript API) but if someone hits my REST endpoint w/o using my library, I still get runtime goodness. The number of different ways that J…

FWIW, I've had good success with Typebox over Zod for exactly this stuff. You don't need to compile out types, you just...have them.

Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees

#46
post #38

Earlier quoted context omitted.

The problem with XSLT wasn't that it was a fundamentally bad design, the problem was the horrible syntax. Well, and namespaces.

what was the problem? there's templates and queries and it seemed pretty clear once you read a quick intro.

syntax < semantics

Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees

#47
post #19
post #6

It really needs comments. Unfortunately it'll never be backwards compatible. It's very helpful for debugging

To me, saying that JSON - not JSON Schema - needs comments is like saying an array - the good old "int[3] foo = { 5, 6, 7 };" - needs comments. I'm sure there are ways to 1) use it profitably without comments and 2) add comments in non-invasive way if really needed.

Isn't that a great example of something that would benefit from comments; a generically named int array with no context?

Regarding the ability to add comments to JSON, it can be done in a cumbersome manner, such as adding a field to an object called "comment", but it is a hack since this wont work for arrays anyway.

Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees

#48

This gives you a pretty good feel for where it’s at: https://json-schema.org/blog/posts/future-of-json-schema I’m invested in it. I’m using it to provide implementation-specific validation of requests to/from a third party API. I wish there was a good macOS editor or IDEA plugin for it with autocomplete etc. The static generators from examples are obscure, ugly, minimal, and can’t account for variations. It isn’t ple…

What are you trying to do in regard to your API? I just developed an extensive API definition using OpenAPI, which (as of version 3.1) is compliant with JSON Schema. I used Stoplight Studio on Mac OS, although it still doesn't fully support OAS 3.1 two years after it became the current OpenAPI standard. The support from tools and generators is terrible; there's still no apparent toolchain that supports version 3.1 from definition through code generation.

Ass-dragging on 3.1 support aside, the code-generation tools out there are, in my experience, trash anyway. It's a massive hodgepodge of Java-based tools with incomplete and redundant documentation repositories all over the place, and widely varying output quality... when the tools work at all. I appreciate people giving their time to open source, but on the other hand I wasted so much time trying to make the broken tools work that I could have written my own code generator from scratch (which is what I ended up deciding to do after weeks of dicking around with OpenAPI Generator).

Anyway, I was just wondering how you're using JSON Schema for API work (since you didn't mention OpenAPI).

Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees

#49
I do use it, and it's a nice additional layer in forcing APIs to a) remain consistent and b) increase security. I think the only public program I'm using it in is my dynamic DNS widget:

https://github.com/chapmajs/dynamic_dns

My main interest in using JSON Schema in the above project was security related: this service sits on the public Internet, by nature I cannot restrict the sources that connect to it (road warrior type systems couldn't send DNS updates!). Having a strict schema is another layer of sanitization on what one nowadays must assume is a malicious source.

Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees

#50
post #34
post #11

Is this the right place to complain about lack of a native Date datatype in JSON? Also lack of inheritance support. (For example I want a way to specify that my json object should be deserialized as Dog not as Animal.)

> Also lack of inheritance support. (For example I want a way to specify that my json object should be deserialized as Dog not as Animal.) Use Typescript, then so long as it barks, you can treat it like a dog! And if it knows how to bark and meow, you can treat it as a dog or a cat at your leisure. :-D

The issue is when JSON has to be parsed on the server using Java/C#. How do you know whether to parse it as a Dog or as a Cat (both of which inherits from Animal)?

Here's Microsoft's workaround: https://devblogs.microsoft.com/dotnet/system-text-json-in-do...

Post reply on HN