14 ms·
JSON Schema Store
- neverrroot 3y agoA repository of over 700 JSON schemas for various file types. Quite useful.
- lolive 3y agoOh my good. This Semantic Web stuff is going live !
- seanp2k2 3y agoJSON is the version of XML we deserve.
- guideamigo 3y agoI wish it had comments. And for that reason, I prefer yaml.
- WirelessGigabit 3y agoI prefer JSON's strictness. A Boolean cannot be confused for a string. In yaml: country: no Now your country is Boolean(false) Now, I still prefer yaml overall. Also, I hate that GitHub actions don't support anchors.
- wyldfire 3y agoThat's a false dichotomy. JSON could have comments and not be ambiguous like YAML. In fact: there exists a specification called JSON5 which does include comments. But I agree that it would've been nice if it had comments before it achieved a critical mass of adoption.
- squeaky-clean 3y agoI don't think they were saying that's an issue of comments, just an issue of yaml vs json.
- euroderf 3y agoI've read the opinion that comments were omitted from JSON in order to forestall hacky round-trip conversions to/from other formats (like XML). Can anyone confirm/deny ?
- mediumsmart 3y agoThe primary reason why JSON does not support comments is that its creator, Douglas Crockford, deliberately removed them from the format to prevent misuse and keep it as a pure data-only format. Crockford observed that some people were using comments to store parsing directives, which could break compatibility between different systems. Hence, the decision to remove comments to maintain the simplicity and consistency of the format across various programming languages and environments. https://www.freecodecamp.org/news/comments-in-json/ https://www.freecodecamp.org/news/comments-in-json/ I vote for the minimalist heretic. https://www.infoq.com/presentations/Heretical-Open-Source/ https://www.infoq.com/presentations/Heretical-Open-Source/
- mminer237 3y agoIn YAML 1.2 that gives the string "no".
- 8organicbits 3y agoHuh, that's a breaking change. yes/y/no/n/on/off are no longer boolean. https://perlpunk.github.io/yaml-test-schema/schemas.html https://perlpunk.github.io/yaml-test-schema/schemas.html
- milliams 3y agoYes, it it. However, it's a breaking change that happened 14 years ago.
- masklinn 3y agoExcept for many yaml implementations either not supporting 1.2 at all (pyyaml, ruby stdlib) or being a weird mix (goyaml) so as to keep working with older files. So when you’re dealing with objective reality, this is still an issue today.
- manojlds 3y agoSo that's been the spec since 2009???
- riwsky 3y agocries in TOML
- guideamigo 3y agoThis is the only example everyone points out against yaml. For Json, there are several such syntactic problems. Unnecessary double quotes and only double quotes everywhere. No dangling comma.
- msm_ 3y agoThese are different kinds of problems. JSON is (arguably) too strict. YAML is (arguably) too loose. One is better for machines, the other is (usually) better for writing by humans by hand. There's no perfect compromise for every use case.
- kondro 3y agoThere’s always JSON5
- Defletter 3y agoTrue, but the multi-line comments give me the ick, and there's still no standard for bigints.
- hackerbrother 3y agoYAML is a fine implementation of JSON with comments.
- devjab 3y agoNobody deserves XML! In all seriousness I get the idea behind XML and I have used a couple of SOAP services which were absolutely brilliant, but as someone who has spent a decade “linking” data from various sources in non-tech enterprise… Well… let’s just say that I’m being kind if I say that 5% of the services which used XML were doing it in a way that was nice to work with. Which is why JSON’s simplicity is such a win for our industry. Because it’s always easy to handle. Sure you can build it pretty terrible, but you’re not going to do this: <y value=x> and then later do <y>x</y> which I’m not convinced you didn’t do in XML because you’re chaotic evil. And you’re not going to run into an issue where some Adobe Lifecycle schema doesn’t work with .Net because of reasons I never really found out because why wouldn’t an XML schema work in .Net? Anyway, I’m sure the intentions behind XML were quite brilliant but in my anecdotal experience it just doesn’t work for the Thursday afternoon programmer mindset and JSON does.
- bryanrasmussen 3y ago>In all seriousness I get the idea behind XML followed by >and I have used a couple of SOAP services which were absolutely brilliant makes me doubt the first part of the statement. If I were to guess what it means is you understand the point of SOAP, and also understand the limitations and problems especially as it relates to uses of XSD in SOAP and the various stack of Web Service specs, but you probably have not had much experience with non-XSD based validation of XML, you do not have any experience with document formats as opposed to data formats, you probably are not familiar with larger international standards like UBL, and not familiar with XML formats that are not so much data or document oriented - SVG, XSL-FO (which admittedly sucks more than is reasonable), GraphML and so forth... A lot of the commenters here are standing up for the value of XML, and I'm not actually with this comment, there are a lot of benefits for using JSON especially when you are using JavaScript all over the place. But saying XML sucks because XSD and SOAP sucks indicates a potential lack of knowledge about the whole subject (perhaps only caused by infelicitous phrasing)
- devjab 3y agoI’m simply trying to say that I think XML sucks because the people who implement it suck, and not because of any technical reasons. Hell, I’m saying that I think XML sucks because it allows people to suck when they use it, myself included.
- crabbone 3y agoA catchy but a meaningless phrase. JSON is a dumpster on fire. Probably in even more ways than XML is. Maybe you deserve it... I feel like I'm being punished by the stupid people who make me use it in a way similar to the sham court hearings from The Planet of Apes.
- VoodooJuJu 3y ago>I feel like I'm being punished by the stupid people who make me use it What's the use-case and what alternative would you prefer?
- crabbone 3y agoThere are multiple contradictory requirements to different things you could want from communication formats. Below are some examples: * You could want to have a universal tool that can examine and understand the contents of the message (for debugging purposes), but you could also want not to send meta-information about the message (s.a. types or sizes etc.) that is essential for parsing the message. And you cannot have both at the same time. * You could want a message format that maps onto the primitive types of a particular language well, but at the same time you may want it to be universal and map to many other languages well. But this is impossible because different languages will have different primitive types and the need to be generic will act against the need of being specific. * You may want to be able to stream data, but this works against hierarchic data organization. * You may want to be able to write messages into pre-allocated memory buffers w/o having to re-calculate the amount of memory necessary to encode a message, but this makes it very hard / impossible to add custom fields and types. --- Given all this, I don't think that JSON is a good match for any use-case it's currently commonly used for. If I want data transfer, I'd go for something like SQL. If I want configuration, I'd go for Datalog. But then I see value in optimizing the transfer of multiple similar records, whereas someone else may see value in optimizing transfer of hierarchically structured data, which isn't necessary repeating. I tried many formats of this kind, and am yet to find a good one. I'm inclined to think that maybe trying to arrange hierarchical data with different constraints on its organization is just a bad approach to data transfer, that the organization and constraints of such data shouldn't be encoded as part of the format, but interpreted by the users of the format. But, if I really had to do this the best way I can image, I'd still go for Datalog.
- andyjohnson0 3y agoWhenever two or more are gathered together, they shall argue about JSON vs XML. Personally I like the simplicity of JSON and also the expressive power of XML. But then I tend to only use each for the task it was primarily intended: application data-on-the-wire in JSON and "documents" in XML. It seems like a lot of the recurrent discussion around these technologies happens when they're pushed to do things outside their comfort zone. And I wonder if some of this is down to siloing of developer knowledge. There was a comment on HN a few days ago (not by me, and I can't find it now) to the effect that web development has historically attracted self-taught developers or those who have come to it by routes like bootcamps. It went on to say that they perhaps consequently lack some knowledge of existing techniques and solutions, and therefore tend to recreate solutions that may already exist (and not always well). And this drives the well-known churn in webdev tech: of which bolting schemas onto JSON is arguably an example. I wonder what people think of this? Personally I think it has some merit, but that the "churn" has also generated (along with much wheel-reinvention) some great innovations. And I say that as someone who works mainly on back-end stuff. Thoughts?
- vonwoodson 3y agoI'd extend this "X developers are mostly self-taught" onto all of computer development. They say, "Every developer Of a Certain Age's first programming language was BASIC" and my experience of (eventually) getting a CS degree is that there is the expectation of students to already know how to do the thing that they are trying to teach; a certain level of "self taught" is expected. To that end, I can see how in The Age of Teh Internets that the standard of self taught has moved of from BASIC to HTML/CSS/JS (or Unity or whatever sparked the young mind's attention). --- What I'm not certain of is that "self taught" means that work will be duplicated because the self taught developer doesn't know the technology that exists. I think that someone who is extremely online will very likely be more abreast of what technologies exist. I think that a formal education is better at establishing what the fundamentals underlying a programing method or paradigm... but not necessarily at exposing new programmers to what the state-of-the-art is.
- thomasfromcdnjs 3y agoJSON Resume uses a defined schema. (listed on schemastore.org) It has made writing resumes with co pilot super powerful.
- nbbaier 3y agoDo you have an example of how you've done this?
- sleepytree 3y agoCan you share your general process for that? Trying to do more AI for this type of thing.
- yawnxyz 3y agoTook me an embarrassingly long time to figure out you could scroll that list
- duxup 3y agoSame,I like how clean it looks but it needs some visual indicator that it scrolls.
- rajamaka 3y agoI see a scroll bar on my browser
- datashaman 3y ago..which only appears when you scroll.
- blackoil 3y agoIn MacOS, set Show scroll bar to always. https://www.macrumors.com/how-to/make-scroll-bars-always-visible/ https://www.macrumors.com/how-to/make-scroll-bars-always-vis...
- wruza 3y agoYour comment made me realize that you can scroll past the list on mobile. I didn’t see Autocompletion section yesterday. Wonders of modern “clean” design.
- mooreed 3y agoDoes anyone know of a typescript translation for each of those validation models? Or maybe even a way to discover related statically typed definitions based on the validation rules? It would be really nice to not define parts of a data model that provide little to no business value - but where you can easily “stub your toe”.
- vorticalbox 3y agoYou could use this[0] package but you would need to download the schema first into a folder say "schemas" and then add a build step as a script in your package.json '"compile-schemas": "json2ts -i schemas -o types"' to export to a "type" folder [0] json-schema-to-typescript
- avx56 3y agoIf it's a one-off you can just use http://borischerny.com/json-schema-to-typescript-browser/ http://borischerny.com/json-schema-to-typescript-browser/ or https://transform.tools/json-schema-to-typescript https://transform.tools/json-schema-to-typescript (they both use the same library).
- tinix 3y agouse quicktype: https://quicktype.io/ https://quicktype.io/
- avel 3y agoAwesome tool, thank you for sharing. I made use of it already!
- RomanAlexander 3y agoI've been asking chatgpt to do it for me.
- andenacitelli 3y agoMost languages have some code generation tool requiring a compile step, but most of the specs in here change infrequently enough you can just do it once and commit to VC. I personally have a use case where I modify the Meltano (ETL tool) spec at runtime and use a generated scheme to validate reads and writes to the file, helping catch bugs early.
- ChrisArchitect 3y ago(2020)? Some previous discussion: https://news.ycombinator.com/item?id=23988269 https://news.ycombinator.com/item?id=23988269
- osigurdson 3y agoIt is interesting that people love json (now with schema), but hate XML while loving HTML at the same time. It is all pretty boring and largely the same imo.
- zdragnar 3y agoThe absolute worst bit of XML is the confused implementations. What should be an attribute on a tag, and what should go between tags? Even worse, nothing is sanely typed without an xsd. Different systems will treat the following differently: <some>true</some> versus <some>1</some> Some systems require the token "true", others will only treat 1 as the boolean true. For example, MS claims that for exchange ASD boolean values must be integer 1 or 0 [0], but then links to a W3C spec that allows for the tokens true and false [1] At least with JSON and HTML, you don't need a separate definition file for basic, primitive data types. [0] https://learn.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-asdtype/dceb8d02-55dc-427a-8d66-8bbf08f4dc26 https://learn.microsoft.com/en-us/openspecs/exchange_server_... [1] https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#boolean https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#boolean
- berkes 3y agoHow is your example any better in JSON? { some: true, someOther: 1, another: "true" }
- likis 3y agoOnly the first one will be treated as a boolean in JSON. The second one is a number, and the third is a string.
- crabbone 3y ago> The second one is a number This would've been useful if you knew what kind of number it was... As for what goes into separate elements and what goes into attributes: a typical answer to this is that simple types (as per XSL) go into attributes, complex types go into elements. Compare this to JSON's screwed-up definition of "hash-tables" (the things in curly braces) which doesn't require that "keys" be unique. XML wasn't perfect. But JSON isn't really better. It sucks in a slightly different way because people keep inventing these formats w/o much thinking, and once discover problems, don't fix them.
- osigurdson 3y agoSee, Steve Ballmer was right after all.
- zurn 3y agoThere are some YAML based schemas there too. How does this work, is there a canonical YAML->JSON transformation, or does JSON schema spec have explicit YAML support? edit: skipping the theoretical foundations, there seems to be at least this tool that claims to validate yaml against json schema: https://github.com/json-schema-everywhere/pajv https://github.com/json-schema-everywhere/pajv
- michaelmior 3y agoYAML is effectively a superset of JSON although the syntax used in YAML is often different. So you can't translate all YAML to JSON, but all JSON can be represented as YAML.
- LispSporks22 3y agoHeh I remember we did similar registry for XML things.
- pasc1878 3y agobut XML allowed an easy way to have distributed schemas not needing a central place. The schema. URI could be made a resource that existed at the URI. The wording gets complex as the URI does not need to exist on the web and that need for exact wording is I suspect a reason for XML to be perceived as complex
- andirk 3y agoDoes this have any relation to https://jsonapi.org/ https://jsonapi.org/ ?
- 8n4vidtmkvmk 3y agoNo.
- JodieBenitez 3y agoLots of comments here about XML vs. JSON... but there are areas where these two don't collide. I'm thinking about text/document encoding (real annotated text, things like books, etc). Even though XML is still king here (see TEI and other norms), some of its limitations are a problem. Consider the following text: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Now say you want to qualify a part of it: Lorem ipsum <sometag>dolor sit amet</sometag>, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Now say you want to qualify another part, but it's overlapping with previous part: Lorem ipsum <sometag>dolor sit <someothertag>amet</sometag>, consectetur</someothertag> adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Of course, this is illegal XML... so we have to do dirty hacks like this: Lorem ipsum <start someid="part1"/>dolor sit <start someid="part2"/>amet<end someid="part1"/>, consectetur<end someid="part2"> adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Which means rather inefficient queries afterwards :-/
- samwillis 3y agoYou are absolutely right that XML is better for document structures. My current theory is that Yjs [0] is the new JSON+XML. It gives you both JSON and XML types in one nested structure, all with conflict free merging via incremental updates. Also, you note the issue with XML and overlapping inline markup. Yjs has an answer for that with its text type, you can apply attributes (for styling or anything else) via arbatary ranges. They can overlap. Obviously I'm being a little hypabolic suggesting it will replace JSON, the beauty of JSON is is simplicity, but for many systems building on Yjs or similar CRDT based serialisation systems is the future. Maybe what we need is a YjsSchema... https://github.com/yjs/yjs/ https://github.com/yjs/yjs/
- thejohnconway 3y agoYjs isn’t a document structure is it? It seems to be a library for collaborative editing, but I’m not seeing something suitable for marking up a document, or am I missing something obvious?
- relequestual 3y agoWe (JSON Schema) did a case study/interview with the guy behind it https://www.youtube.com/watch?v=-yYTxLZZk58&list=PLHVhS4Tj1YZOrrvl7_a9LaBAtst7BWH8a&index=3 https://www.youtube.com/watch?v=-yYTxLZZk58&list=PLHVhS4Tj1Y...
- jhoechtl 3y agoIS there an on-premise alternative? Not necessarily speaking of schemastore.org on prem but a service comparable in spirit.
- unilynx 3y agoThe 'service' is basically hosting this file: https://www.schemastore.org/api/json/catalog.json https://www.schemastore.org/api/json/catalog.json - you could host that locally and point your software to it, modifying the other URLs where needed It's a pity the catalog format doesn't support an 'import' or relative URLs for schemas - would have made local extensions a bit easier.
- andenacitelli 3y agoJSON Schemas are great. These are actually what IntelliJ uses to validate all sorts of config files behind the scenes. For work, we even do code generation off of the Meltano (ETL tool) spec and use it to validate reads and writes to the file (which we edit at application runtime) to catch errors as close to when they actually occur.
- albert_e 3y agois there a good tool or library to create a JSON Schema manually/programmatically ?
- mdaniel 3y agoIts autocomplete story is a mess, but https://github.com/Kong/insomnia#readme https://github.com/Kong/insomnia#readme at least allows one to visualize any schema authored in the document (it generates examples as well as a schema browser). It's possible that other OpenAPI tools behave similarly, I just happen to have the most hand's on with Insomnia for example: openapi: 3.0.0 info: title: this is my title description: a long description goes here version: v1 servers: - url: http://127.0.0.1:9090 description: the local server paths: /thingy: get: responses: "200": description: ok content: application/json: schema: $ref: '#/components/schemas/Thingy' components: schemas: Thingy: type: object properties: alpha: type: boolean as for the "create automatically," I'd guess that's a genuinely hard problem although if your example documents are simple/homogeneous enough you may get away with it ok: [{"alpha": true}, {"alpha":false}] problematic: [ {"alpha":{"beta": ["charlie", 3.1415, null]}}, {"alpha":[{"beta":null}]}, {"alpha": null} }
- beanaroo 3y agoI like to use zod for Typescript and Pydantic for python. https://github.com/StefanTerdell/zod-to-json-schema https://github.com/StefanTerdell/zod-to-json-schema https://docs.pydantic.dev/latest/usage/json_schema/ https://docs.pydantic.dev/latest/usage/json_schema/
- Fatal1ty 3y agoYou can find a suitable tool on the official website https://json-schema.org/implementations.html#schema-generators https://json-schema.org/implementations.html#schema-generato...
- albert_e 3y agocan JSON achema be used to describe say the schema of a RDBMS table? is these some standardization here so I might use a JSON schema that already covers a lot of the fields that are needed to describe columns, constraints etc? can JSON schema capture relations between fields?
- tristan957 3y agoI would check out the OpenAPI specification[0]. Specifically, look at the "Components" section. It might help you out. [0]: https://swagger.io/specification/ https://swagger.io/specification/