Live data from Hacker News

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

news.ycombinator.com

21–30 of 179 posts

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

#21

Here'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.

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

#22
post #11

Is 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.)

Lets invent JAYSON :D

   (dog){
      "ears": [(ear){"side": "right"}, (ear){"side": "left"}]
      {% this is a comment %}
   }

Now we only have to invent attributes, and we can sell this XML skin to the enterprise JSON users.

(This is only half sarcasm)

EDIT: Even Better, make comments a subtree by having a special type tag, like #. this way, (#,dog){...} can stay in the tree, but is ignored.

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

#23
post #17
post #14

Earlier quoted context omitted.

That's jq. At least useful for a lot of transformations.

A little different, but yeah. (If I'm not mistaken, xslt had a bit more of a defined language and way more formalism.) That said, there are plenty of examples. JSONPath, JQ, Jolt... I am not claiming that this is not useful. Just amused to see the wheel go around.

Oh, it absolutely goes around in this industry.

For a simple, most frequently used subset of jq a more modest, non-Turing-complete language of transforming strings could be created, so that for many useful cases one just need to provide such a string. Strictly for JSON -> JSON.

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

#24
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].

[1] https://www.umami.recipes [2] https://schema.org/Recipe [3] https://github.com/google/schema-dts

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

#25
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.

JSONschema uses jsonpointer.

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

#26
I use JSONschema, it's honestly great the way it is [0]. So I guess the guarantee I want is "don't change anything"? Ha.

[0] my biggest gripe is it's not well defined what to do with multipleOf when the number isn't an exact integer.

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

#27
This gives you a pretty good feel for where it’s at: https://json-schema.org/blog/posts/future-of-json-schema

I’m invested in it. I’m using it to provide implementation-specific validation of requests to/from a third party API.

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.

Nevertheless I’d rather write API validation this way, in a document, than in code.

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

#28
post #8

Here'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.

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 giving this feedback in a context that you think isn't appropriate, but in either case I think it would be more effective to just state your point directly instead of passive-aggressively.

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

#30
post #11

Is 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.)

I think JSON allows both of your use cases, you'll just have to define your own deserialization.

We've used { "__type": "DOG" } as metadata flags in GraphQL and JSON API's for a long time.

I rarely see an API return anything other than an ISO8601 UTC datetime string anymore other than Xero's horrific .NET(?) string " /Date(1326480130277+1300)/"

Post reply on HN