Live data from Hacker News

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

news.ycombinator.com

121–130 of 179 posts

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

#121

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). Making sure there aren'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'd have to deploy native apps int…

The OP actually created a tool that allows you to upgrade your schemas between versions of JSON Schema. It's pretty neat, and has had the eyes of those who write the spec. https://github.com/sourcemeta/alterschema

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

#122
post #73

I reviewed JSON Schema libraries for Haskell: https://github.com/sshine/library-recommendations/blob/main/... My current impression is that JSON Schema is nicer in theory than in practice.

Thanks for sharing. This is useful commentary to see. We try to be helpful to maintainers. If any have questions, the JSON Schema server has an implementers channel! We would like to be able to support implementers financially, but we need other companies to add their support in order to do that. And for that, we need to better communicate our value proposition. We're working on it!

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

#123
post #9

Regarding explicit guarantees, I'd consider a "forward-compatible" way such that when - and if - a breaking change needs to be introduced, it'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't be better. As is often the case, good domain knowledge can help to choose which features a…

A project exists which does this, and the team even support its development: https://github.com/sourcemeta/alterschema

Personally, I'd like to see it become officially supported. We have work to do!

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

#124

Earlier quoted context omitted.

Decimal types don't exist in JSON. If you need decimals, you definitely should encode them as strings. As JSONschema exists to document JSON, it should be agnostic to that. You can if you wish, provide format information in the format field, which is not prescriptive.

Neither binary nor decimal floating point types exist in the JSON spec. The JSON spec does not give an explicit internal representation for floating points, implementations are free to use decimal types internally, if they wish to do so. The JSON spec merely specifies what a "number" is at the grammar level. Having said that most implementations don't use decimal floating points to represent these.

It is a scandal that JSON does not support the BigInt type.

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

#125

Earlier quoted context omitted.

Zod schemas are the source of truth, from which TS types are inferred and JSON schemas are generated.

Interesting.. I'd rather write typescript types than Zod schemas. I haven't used JSON schema, but going TS to Zod was straightforward and really pleasant

Typescript can't understand types as objects, but it can understand objects as types (using typeof). So starting with objects and generating types is more natural.

Also if you start with objects you can express runtime conditions that are not possible with types, for example maximum sizes.

Zod is quite a bit more general than JSON schema because it can express transformations not just validations.

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

#126
it would be nice if you did provide a guid of things tool implements get commonly wrong

like you would expect that people realize "additionalProperties" are additional to "properties" 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)

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

#127
post #7

Soon 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.

next is using a (subset) of typescript for human consumption and concert that to json for machine consumption

because one thing is for sure, json schema and openapi are not really nicely readable, even if written as yaml

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

#128
post #7

Soon 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.

You know what is funniest part is?

JSON Schema is something that address stability guarantees for JSON - where JSON was invented to be easy to change so it skips heavy XML stuff that was giving stability guarantees.

Now people involved in JSON Schema have problem with decision on stability guarantees - if they skip those or keep it backwards compatible...

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

#129
post #100

Earlier quoted context omitted.

We already use comments in JSON without JSONC in lots of projects. Adding a { "//": "My Comment" } line works and most API's ignore excess fields.

A good json schema validator will usually reject excess fields.

Actually, currently, this is not the case. The specification explicitly allows for additional fields for the purposes of extensions. We are considering changing that, and only allowing pre-defined fields, or having a way to mark specific fields as limited extensions.

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

#130
> Do you use JSON Schema?

No, but I don’t do much backend stuff, anymore.

I’m totally anal about Quality, so I want 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.

XML Schema is a huge 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.

The main reason I don’t use jsonSchema, is that I don’t have a real use for it, these days.

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.

Post reply on HN