It really needs comments. Unfortunately it'll never be backwards compatible. It's very helpful for debugging
Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
31–40 of 179 posts
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#32Here's my gripe with jsonschema... In most cases where I want to do some validation on JSON I find that I usually have a class/struct/object that represents the payload and I want to unpack JSON into it (or dump that class to JSON). Ultimately, there are already nice tools to do this (eg; marshmallow on the python side). So unless I'm crossing language boundaries writing a separate jsonschema and using that is more w…
Since you use python you might be interested in knowing that Pydantic outputs JSON Schema as an option. This is part of how FastAPI is able to generate OpenAPI specs (OpenAPI uses JSON Schema for a lot of validation). The only time I've needed to use JSON Schema I just used Pydantic models as my source of truth.
The application I'm working on predates FastAPI, so I'm using CherryPy and modified their JSON tool to call the parse_obj() and json() on the model where needed.
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#33Here's my gripe with jsonschema... In most cases where I want to do some validation on JSON I find that I usually have a class/struct/object that represents the payload and I want to unpack JSON into it (or dump that class to JSON). Ultimately, there are already nice tools to do this (eg; marshmallow on the python side). So unless I'm crossing language boundaries writing a separate jsonschema and using that is more w…
In theory this is already supported - ish. Because unknown keys at any level of the spec are ignored… but how does one know that those keys will always be unknown? The specification should do something like say certain keys, say, any with a period in the key name, will never be used by the core specification as it evolves. It’s a bit unclear from the spec at https://json-schema.org/draft/2020-12/json-schema-core.html#... IMO. This is why this thread is important!
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#34Is 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.)
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
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#35Is 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.)
No, it's not the right place.
Date type reminds about some network-specific types which used to be in older version of JSON Schema (like IPv4 address?). Today we can use a string with regexp for an approximation. Do we have a mechanism in JSON Schema to define, mmm, dialects?..
Deserialization of a number as an integer, not a double, could be a similar problem. We can agree that we (try to) deserialize to most abstract class (?) or to use external explicit indicators of the class.
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#36I 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 JSON schema can be programmatically generated and therefore expressed is a bit high, different tools generate very different JSON Schemas.
Also the error messages JSON schema gives back are kind of trash, then again the JSON Schema on one of our endpoints is over 200KB in size.
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#37Earlier quoted context omitted.
Wonder in which language class members can have such JSON Schema requirements as "an integer which is a multiple of integer X" or "string which matches regexp R". Also not sure which other schema system is better than JSON Schema across many different features.
They're saying that the tool doesn't fit their priorities for their use case. I suspect you might be trying to say that their use case isn't what the tool is designed for, but you've phrased it in a way that comes across as condescending for not knowing what the tool even does. I'm not sure if you're trying to convince them that the tool would in fact be superior for their use case or if you're unhappy with them for…
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#38Soon we'll have JSLT. JSON Query, JSON Pointer, JSON signatures etc are already there. And I say that as a conscious XML user. We are going in circles. At least XML has comments.
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#39Here's my gripe with jsonschema... In most cases where I want to do some validation on JSON I find that I usually have a class/struct/object that represents the payload and I want to unpack JSON into it (or dump that class to JSON). Ultimately, there are already nice tools to do this (eg; marshmallow on the python side). So unless I'm crossing language boundaries writing a separate jsonschema and using that is more w…
Wonder in which language class members can have such JSON Schema requirements as "an integer which is a multiple of integer X" or "string which matches regexp R". Also not sure which other schema system is better than JSON Schema across many different features.
Any language with a half-decent type system can represent that at the type level. And certainly any language worth knowing can trivially check whether an integer is a multiple of integer X or a string matches regexp R, which is what grandparent was getting at.
Re: Ask HN: Do you use JSON Schema? Help us shape its future stability guarantees
#40Soon we'll have JSLT. JSON Query, JSON Pointer, JSON signatures etc are already there. And I say that as a conscious XML user. We are going in circles. At least XML has comments.
The problem with XSLT wasn't that it was a fundamentally bad design, the problem was the horrible syntax. Well, and namespaces.