News for hackers. Stuff that matters.
Re:Show HN: Verify JSON using minimal schema by eventreduce on Thursday April 16, 2020 @03:55AM (#22887146)
I think the author knew this but wanted a more minimal type of validation.
Re:Show HN: Verify JSON using minimal schema by arethuza on Thursday April 16, 2020 @04:15AM (#22887254)
Json schema does scale down pretty well (indeed as the link above shows the simplest possible Json schema is just "{}") - it also has pretty good tool support (e.g. VS Code) - there is a Json schema for Json schemas which helps a lot.

The main advantage of the approach in the article appears to be that its easy to extend validation with code - which is a nice touch. Pretty much any complex Json validation I have written has to combine both schema based validation and code based checks - usually done completely separately.

Re:Show HN: Verify JSON using minimal schema by xg15 on Thursday April 16, 2020 @06:35AM (#22887979)
> Json schema does scale down pretty well (indeed as the link above shows the simplest possible Json schema is just "{}")

I've not used JSON Schema so far, but I think showing the simplest possible definition does not tell much about how complex or easy to use a language is.

E.g., it's easy to write C code for a working program that does nothing or just prints "Hello World". The resulting code is very simple and can be written without much experience in C.

However that doesn't make C a simple language - and indeed writing programs in C that perform useful tasks is a lot more complex and requires more knowledge about the language.

In the same way, it's nice that Json Schema has a compact syntax for the "do nothing" schema, but I think a comparison between practically used examples would be better.

(Also the "do nothing" schema would have to compare against not doing schema validation at all - and compared to that, even the two brackets are still pretty costly)

Re:Show HN: Verify JSON using minimal schema by eventreduce on Thursday April 16, 2020 @05:22AM (#22887574)
Json-schema itself scales down pretty well. But the libraries for validating it do not. Even if your schema is only {}, the build size increment because of pulling in a jsonschema validator is enormous because of all these supported features.
Re:Show HN: Verify JSON using minimal schema by arethuza on Thursday April 16, 2020 @05:34AM (#22887639)
Fair enough I guess - don't think I've ever had a need to do client side JSON validation against a 'schema' so I've never had that concern.