TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

263 pointsby jviottiover 2 years ago
The JSON Schema organization is requesting feedback from users out there about the stability guarantees it should be enforcing on the next release of the specification.<p>If you feel you can contribute, please read <a href="https:&#x2F;&#x2F;github.com&#x2F;orgs&#x2F;json-schema-org&#x2F;discussions&#x2F;295">https:&#x2F;&#x2F;github.com&#x2F;orgs&#x2F;json-schema-org&#x2F;discussions&#x2F;295</a> and share your thoughts.<p>The current options are:<p>- The specifications that have been published to date provide no stability guarantees, but we will be adding explicit guarantees with the next publication.<p>- Apply the stability guarantees starting with the most recent publication (draft 2020-12) so that the next publication contains no breaking changes.

36 comments

com2kidover 2 years ago
JSON Schema is awesome. I wish Typescript had better support for it though, having to do stuff in Zod and JSON Scheme sucks.<p>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&#x2F;o using my library, I still get runtime goodness.<p>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.<p>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.
评论 #34589159 未加载
评论 #34593995 未加载
评论 #34598785 未加载
评论 #34590723 未加载
user3939382over 2 years ago
This gives you a pretty good feel for where it’s at: <a href="https:&#x2F;&#x2F;json-schema.org&#x2F;blog&#x2F;posts&#x2F;future-of-json-schema" rel="nofollow">https:&#x2F;&#x2F;json-schema.org&#x2F;blog&#x2F;posts&#x2F;future-of-json-schema</a><p>I’m invested in it. I’m using it to provide implementation-specific validation of requests to&#x2F;from a third party API.<p>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 pleasant to write, it’s tedious and slow.<p>Nevertheless I’d rather write API validation this way, in a document, than in code.
评论 #34589111 未加载
评论 #34589603 未加载
评论 #34589188 未加载
ysleepyover 2 years ago
Soon we&#x27;ll have JSLT. JSON Query, JSON Pointer, JSON signatures etc are already there.<p>And I say that as a conscious XML user. We are going in circles. At least XML has comments.
评论 #34589690 未加载
评论 #34588705 未加载
评论 #34589059 未加载
评论 #34589853 未加载
评论 #34589402 未加载
评论 #34593553 未加载
评论 #34593425 未加载
评论 #34589456 未加载
评论 #34588759 未加载
评论 #34588901 未加载
Tayweeover 2 years ago
I use JSON schema to generate JSON-editing forms via json-editor: <a href="https:&#x2F;&#x2F;github.com&#x2F;json-editor&#x2F;json-editor">https:&#x2F;&#x2F;github.com&#x2F;json-editor&#x2F;json-editor</a><p>Then I can use the same schema in the backend to validate the data, both sent in via the form and directly with the application&#x2F;json content-type. It&#x27;s a pretty smooth flow, and reduces a lot of redundancy.
throwawaymathsover 2 years ago
I use JSONschema, it&#x27;s honestly great the way it is [0]. So I guess the guarantee I want is &quot;don&#x27;t change anything&quot;? Ha.<p>[0] my biggest gripe is it&#x27;s not well defined what to do with multipleOf when the number isn&#x27;t an exact integer.
评论 #34589149 未加载
评论 #34606050 未加载
drdaemanover 2 years ago
Would love an standardized ability to specify some human-readable annotation for a validation rule and then an ability to easily see this in the DETAILED or VERBOSE validation format. I.e. rather than a cryptic note that something doesn&#x27;t match a `pattern: &quot;\\S&quot;` (best your typical library would do) I wanna say &quot;must contain at least one non-whitespace character&quot;. And I want this standardized, so any conformant library I pick would be able to do this for me, providing a consistent experience whenever it&#x27;s UI-side &quot;on-the-fly&quot; pre-validation or processing a submission. Unless I missed it, I think while some libraries can do this, it&#x27;s not exactly standardized thing.<p>And maybe schema URIs weren&#x27;t exactly the best idea. Not a fan how many libraries make me register a schema with some a fake URL instead of just feeding them the schema document and simply not caring where it came from at all. But since it&#x27;s already there - OK, fine, it&#x27;s a minor nuisance.<p>Otherwise, it just works.<p>P.S. I have no idea about the relation to OpenAPI&#x2F;Swagger&#x2F;RESTful APIs&#x2F;whatever. I use vanilla JSON Schema as a convenient &quot;cross-platform&quot; DSL for JSON-serializable data structure validation, and I think it does excellent job at this. Would love to see it staying in that scope.
IanCalover 2 years ago
I feel like this is missing an important bit of context, at least it&#x27;s not obviously part of this discussion though I expect it&#x27;s known somewhere.<p>Keeping things compatible is essentially always preferable. Making breaking changes is in isolation a bad thing but can be worth it for what you get out of it.<p>Is there a wishlist of &quot;if only we could break compatibility, we&#x27;d do X&#x2F;Y&#x2F;Z&quot;?<p>&gt; The specifications that have been published to date provide no stability guarantees, but we will be adding explicit guarantees with the next publication. However, it seems disingenuous to promise &quot;no breaking changes&quot; while including breaking changes.<p>Not really, this seems pretty par for the course of any project hitting a 1.0 release - announcing that things are <i>now</i> stable. Perhaps that&#x27;s a better framing, you wouldn&#x27;t release something saying no breaking changes while containing breaking changes, but releasing something that has breaking changes as a <i>stable</i> thing makes a lot of sense.
MithrilTuxedoover 2 years ago
I have been trying to get anyone to use it since I discovered FasterXML&#x2F;Jackson could generate it.<p>I have not worked for an organization with public APIs. Not a single one of the APIs I work on is completely stable. Figuring out what our APIs do requires techniques from archeology, anthropology, and sociology.
评论 #34588803 未加载
AdieuToLogicover 2 years ago
&gt; Do you use JSON Schema?<p>At one point I did, but then discovered RAML[0] and it subsumed the value of what JSON Schema provides as well as being easier to work with than OpenAPI[1]. Also, generating JSON Schema from RAML definitions has proven to be a fairly straightforward process.<p>The usual caveats apply... Your mileage may vary, my experiences do not speak for any others, my opinion does not detract from the value of JSON Schema, etc.<p>0 - <a href="https:&#x2F;&#x2F;github.com&#x2F;raml-org&#x2F;raml-spec&#x2F;blob&#x2F;master&#x2F;versions&#x2F;raml-10&#x2F;raml-10.md&#x2F;">https:&#x2F;&#x2F;github.com&#x2F;raml-org&#x2F;raml-spec&#x2F;blob&#x2F;master&#x2F;versions&#x2F;r...</a><p>1 - <a href="https:&#x2F;&#x2F;swagger.io&#x2F;specification&#x2F;" rel="nofollow">https:&#x2F;&#x2F;swagger.io&#x2F;specification&#x2F;</a>
评论 #34592652 未加载
nextaccounticover 2 years ago
I&#x27;m not currently using it, but I&#x27;m strongly considering validating json in postgres with <a href="https:&#x2F;&#x2F;github.com&#x2F;supabase&#x2F;pg_jsonschema">https:&#x2F;&#x2F;github.com&#x2F;supabase&#x2F;pg_jsonschema</a> - which uses the <a href="https:&#x2F;&#x2F;docs.rs&#x2F;jsonschema&#x2F;latest&#x2F;jsonschema&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;jsonschema&#x2F;latest&#x2F;jsonschema&#x2F;</a> Rust crate<p>So I&#x27;m not sure if my feedback is valid but, I sure hope that the jsonschema crate follows the spec! Otherwise I&#x27;ll never use jsonschema but instead something-not-exactly-jsonschema. In other words.. you better not break anything.
评论 #34595086 未加载
jackconsidineover 2 years ago
Started using it for my site. Have a hard time navigating the docs and understanding the best types of schema for different purposes. Is there a great guide that anyone knows of?
评论 #34588826 未加载
harsha_chover 2 years ago
We at OpenMetadata(<a href="https:&#x2F;&#x2F;open-metadata.org" rel="nofollow">https:&#x2F;&#x2F;open-metadata.org</a>) use JsonSchema extensively to define the metadata standards. JsonSchema is one of the reasons we are able to ship and get the project to what it is today in quick time. More about it here <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ZrVTZwmTR3k">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=ZrVTZwmTR3k</a>
yusufnbover 2 years ago
I considered using it some time back for API payload validations. I found it bit too verbose for my use case then. I ended up writing my own lighter version and it worked pretty well. I later open sourced it here - <a href="https:&#x2F;&#x2F;github.com&#x2F;sleeksky-dev&#x2F;alt-schema">https:&#x2F;&#x2F;github.com&#x2F;sleeksky-dev&#x2F;alt-schema</a> .
评论 #34590931 未加载
petilonover 2 years ago
Is this the right place to complain about lack of a native Date datatype in JSON?<p>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.)
评论 #34588895 未加载
评论 #34589019 未加载
评论 #34594442 未加载
评论 #34588939 未加载
评论 #34592437 未加载
评论 #34588771 未加载
seerover 2 years ago
I use it extensively in prod. Well the superset that is OpenApi. It enables contract first development where any change to the api is done in the schema fist, and then implemented by the clients&#x2F;server.<p>Since we have tooling[0] that validates requests and responses at runtime, the clients can be absolutely sure of what they receive (we through 500 if the server attempts to respond with an undocumented respond) And the server is also sure about the shape of the requests. This allows us to validate everything at compile time too, generating typescript types for both client and server.<p>And since we have similar tooling regarding our data stores (typescript types for sql queries) most of the time if there is a bug, the code would simply not compile - pretty nifty!<p>[0] - <a href="https:&#x2F;&#x2F;github.com&#x2F;ovotech&#x2F;laminar">https:&#x2F;&#x2F;github.com&#x2F;ovotech&#x2F;laminar</a>
评论 #34595144 未加载
alfalfasproutover 2 years ago
Here&#x27;s my gripe with jsonschema...<p>In most cases where I want to do some validation on JSON I find that I usually have a class&#x2F;struct&#x2F;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&#x27;m crossing language boundaries writing a separate jsonschema and using that is more work and I have to keep it up to date.<p>And in the cases where I want to cross language boundaries at this point there&#x27;s less and less of a compelling case to go with JSON and not eg; flatbuffers&#x2F;protobuf&#x2F;thrift&#x2F;capnproto since you&#x27;re writing a schema anyways.
评论 #34588802 未加载
评论 #34589008 未加载
评论 #34588874 未加载
评论 #34588677 未加载
评论 #34590974 未加载
评论 #34592576 未加载
ChrisMarshallNYover 2 years ago
<i>&gt; Do you use JSON Schema?</i><p>No, but I don’t do much backend stuff, anymore.<p>I’m totally anal about Quality, so I <i>want</i> to do things like jsonSchema. I used to deliberately publish APIs in both JSON and XML, so that I could use XML Schema to validate the data, but JSON, to actually use it.<p>XML Schema is a <i>huge</i> PItA. I don’t like auto-generated Schema (see “anal,” above), so I tend to hand-tune (or write code to dynamically generate) my Schema.<p>The main reason I don’t use jsonSchema, is that I don’t have a real use for it, these days.<p>I mostly have internal APIs (proprietary backends), so there’s no need. I do have one backend that I recently wrote, that is public, and I may consider adding a published schema to it.
评论 #34593649 未加载
systems_glitchover 2 years ago
I do use it, and it&#x27;s a nice additional layer in forcing APIs to a) remain consistent and b) increase security. I think the only public program I&#x27;m using it in is my dynamic DNS widget:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;chapmajs&#x2F;dynamic_dns">https:&#x2F;&#x2F;github.com&#x2F;chapmajs&#x2F;dynamic_dns</a><p>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&#x27;t send DNS updates!). Having a strict schema is another layer of sanitization on what one nowadays must assume is a malicious source.
karmelappleover 2 years ago
We use JSON Schema, and we have had nary a problem with storing a bunch of JSON documents in a variety of no-SQL databases for many years now (knock on wood because yikes that a bold sentence to write).<p>Making sure there aren&#x27;t major breakages from one version to the next sure would be nice, yes. We hit some snags as we attempted to upgrade from I believe 4 to 7, especially because we&#x27;d have to deploy native apps into the wild to use the newer version, and getting native mobile apps deployed everywhere quickly is an exercise in futility.<p>So being able to be confident that draft X will work with draft X+1 would be pretty excellent.
评论 #34593172 未加载
stevebmarkover 2 years ago
I haven&#x27;t used JSON Schema (knowingly, at least) in my professional software career. I wonder why that is. There are things that seem to supersede it, namely type systems. GraphQL types with compiled clients wouldn&#x27;t have a need for this (I don&#x27;t think?). Neither would Golang generated clients from GraphQL specs, nor gRPC&#x2F;protobufs. JSON storage &#x2F; data passing within applications is covered by Typescript.<p>For libraries that build&#x2F;offer specific JSON outputs (maybe like an online editor that dumps out a JSON file on export), I would also expect that product would come with a client library with Typescript types that would give type safe access to the JSON data.<p>Maybe JSON schema is useful for RESTful resources to provide a payload definition of responses? And I guess consumers could then generate client definitions from the JSON schema? It seems weird to do that at runtime, so I&#x27;m guessing it would also be a compile step to generate clients from JSON schema? Or is there an intentional runtime use case?<p>Are there popular APIs&#x2F;libraries&#x2F;etc that use JSON Schema? I don&#x27;t see a &quot;used by&quot; section on this site which could help folks understand where this sits in the modern software development industry.
评论 #34590298 未加载
评论 #34590341 未加载
评论 #34590781 未加载
评论 #34590496 未加载
评论 #34590178 未加载
Jemaclusover 2 years ago
My struggle with JSON Schema is that not everyone uses it! I do a lot of work with various APIs and ingestion systems that accept JSON, but they don&#x27;t provide a JSON Schema for me to validate my payloads against. Instead, I often have a human being on the other side emailing me and saying, &quot;Your data structure isn&#x27;t correct.&quot;<p>It&#x27;s mildly infuriating. I&#x27;ve taken to using Cuelang[0] to write my own validators based on their specifications. (Using Cue because JSON isn&#x27;t the only data format I have to support.)<p>I wish there were an easier way to take some documentation and generate JSON Schema from it. I can take the sample JSON in the docs and generate one, but those samples don&#x27;t usually contain all the edge cases that the systems complain about, so it&#x27;s not super useful.<p>[0] <a href="https:&#x2F;&#x2F;cuelang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cuelang.org&#x2F;</a>
sshineover 2 years ago
I reviewed JSON Schema libraries for Haskell:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;sshine&#x2F;library-recommendations&#x2F;blob&#x2F;main&#x2F;recommendations&#x2F;haskell-json-schema.md">https:&#x2F;&#x2F;github.com&#x2F;sshine&#x2F;library-recommendations&#x2F;blob&#x2F;main&#x2F;...</a><p>My current impression is that JSON Schema is nicer in theory than in practice.
评论 #34593232 未加载
homeroover 2 years ago
It really needs comments. Unfortunately it&#x27;ll never be backwards compatible. It&#x27;s very helpful for debugging
评论 #34588861 未加载
评论 #34590594 未加载
评论 #34589678 未加载
评论 #34588850 未加载
评论 #34589108 未加载
评论 #34588962 未加载
评论 #34591178 未加载
avmichover 2 years ago
Regarding explicit guarantees, I&#x27;d consider a &quot;forward-compatible&quot; way such that when - and if - a breaking change needs to be introduced, it&#x27;s possible to automatically convert old JSON schemas into the new one. JSON Schema version which would select which processing to choose could be an option, but not sure if there couldn&#x27;t be better.<p>As is often the case, good domain knowledge can help to choose which features are &quot;real&quot; and can stand and which are more doubtful and have a higher chance to fall out of favor later.
评论 #34593247 未加载
thebricklayrover 2 years ago
Just last week, I added the ability to export Umami[1] recipes as Recipe JSON Schema[2]. Writing the code for it was quite pleasant thanks to schema-dts[3].<p>[1] <a href="https:&#x2F;&#x2F;www.umami.recipes" rel="nofollow">https:&#x2F;&#x2F;www.umami.recipes</a> [2] <a href="https:&#x2F;&#x2F;schema.org&#x2F;Recipe" rel="nofollow">https:&#x2F;&#x2F;schema.org&#x2F;Recipe</a> [3] <a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;schema-dts">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;schema-dts</a>
macraelover 2 years ago
I&#x27;ve been storing some document data in my app in a protobuf in part because I thought protobuf&#x27;s support for an evolving schema would help with this data aging gracefully over time. But protobufs in js are worse than I thought they would be so I&#x27;m considering trying the same strategy out with JSON Schema instead. Any reason why that wouldn&#x27;t work? JSON is so much easier to work with in js than protos.
comprevover 2 years ago
I built a tool which uses JSONschema for validating custom policy documents as part of a GitHub Action pipeline. The documents get processed for updating HashiCorp Vault, and being able to validate&#x2F;restrict fields like &quot;email address domain&quot; keeps InfoSec happy.<p>Part of my motivation to build the tool was to learn more about JSONschema.
dathinabover 2 years ago
it would be nice if you did provide a guid of things tool implements get commonly wrong<p>like you would expect that people realize &quot;additionalProperties&quot; are additional to &quot;properties&quot; but pretty much any doc or code gen tooling I have used has some problems with getting that right (various problem not always the same)
ephaetonover 2 years ago
I use json schema to communicate the potential shape of JSON input and output to co-workers who have to produce or consume said JSON, and use it to validate incoming requests via valijson. It&#x27;s somewhat clunky. Stability guarantees? Well, it&#x27;s all namespaced anyways, isn&#x27;t it.
评论 #34592998 未加载
osigurdsonover 2 years ago
Are there any good libraries for translating data from one json schema to another (i.e. data upgrade)? I&#x27;m not worried about a particular language, I&#x27;d just like to see what is available.
jcimsover 2 years ago
Many of the orgs I&#x27;ve encountered through the years focus on mechanisms to implement and share APIs by way of method signatures. Is it possible to build an ecosystem around data schemas?
yieldcrvover 2 years ago
just commentary on JSON Scheme itself:<p>I mainly seem to have no leapfrogged the need for this<p>There was a time when the JSON parsers across different platforms were so finicky that schemas seemed like a solution, but the parsers got better at not breaking on unexpected data types or JSON structures<p>I&#x27;m also usually able to do system design to return a smaller subset of data, with consistent data types<p>Or someone else&#x27;s JSON or JSON output has its own documentation that already tells what something is and how it should be parsed
评论 #34591185 未加载
nlyover 2 years ago
We just use protobufs JSON serialisation. It&#x27;s a lot easier.
评论 #34593964 未加载
RandomWorkerover 2 years ago
Allow for single quotes when they are the only quotes to define a key or value. Similar to python strings. This would be huge for me.
daviddever23boxover 2 years ago
Just used it last week for some extensions to existing schema.
anon223345over 2 years ago
Schema.org