Live data from Hacker News

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

news.ycombinator.com

61–70 of 179 posts

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

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

At this rate, we'll be back to S-expressions in 50 years or so.

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

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

I miss working with xslt - I was once handed an API specified in xsd and we wrote an xslt script that turned it into an SQL script that built all the tables and insert/update/delete stored procedures so we could log all the calls.

I guess you could do something like that with redis but at the time it was magic.

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

#64
post #6

It really needs comments. Unfortunately it'll never be backwards compatible. It's very helpful for debugging

> It really needs comments. Unfortunately it'll never be backwards compatible. It's very helpful for debugging If you want to have comments, consider using YAML for definitions where possible as it is a superset of JSON[0]: YAML is also a superset of JSON, so JSON files are valid in YAML. 0 - https://www.redhat.com/en/topics/automation/what-is-yaml

Just for fun, I wondered if YAML '#' comments could exist within a multi-line formatted JSON file.

I cannot say the below holds for all YAML libraries, but can say the below works.

Assume there is a file named "foo.yaml" which has the following content:

  {
    # this is a comment
    "hello" : "world",
    array : [
      # first number
      1,
  
      # second number
      2
      ]
  }
Running:

  ruby -ryaml -rjson -e 'puts JSON.pretty_generate(YAML.load(ARGF))' 
Yields the below without error:

  {
    "hello": "world",
    "array": [
      1,
      2
    ]
  }
HTH

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

#65

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…

Here's my gripe with random HN comments: this has nothing to do with stability guarantees of the specification or not, unless I'm missing something in your comment. You basically just saw "JSON Schema" and thought "Aha, JSON Schema, here is why I don't like it at all, regardless of why you started this conversation"

"Ask HN: Do you use JSON Schema?" was complete thought too

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

#66
I've been storing some document data in my app in a protobuf in part because I thought protobuf'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'm considering trying the same strategy out with JSON Schema instead. Any reason why that wouldn't work? JSON is so much easier to work with in js than protos.

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

#67
I haven'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't have a need for this (I don't think?). Neither would Golang generated clients from GraphQL specs, nor gRPC/protobufs. JSON storage / data passing within applications is covered by Typescript.

For libraries that build/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.

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'm guessing it would also be a compile step to generate clients from JSON schema? Or is there an intentional runtime use case?

Are there popular APIs/libraries/etc that use JSON Schema? I don't see a "used by" section on this site which could help folks understand where this sits in the modern software development industry.

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

#68
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 into the wild to use the newer version, and getting native mobile apps deployed everywhere quickly is an exercise in futility.

So being able to be confident that draft X will work with draft X+1 would be pretty excellent.

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

#69

I haven'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't have a need for this (I don't think?). Neither would Golang generated clients from GraphQL specs, nor gRPC/protobufs. JSON storage / data passing within applications is covered by Typescript. For librari…

I've used JSON Schema for specifying YAML config schemas.

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

#70

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 ple…

What are you trying to do in regard to your API? I just developed an extensive API definition using OpenAPI, which (as of version 3.1) is compliant with JSON Schema. I used Stoplight Studio on Mac OS, although it still doesn't fully support OAS 3.1 two years after it became the current OpenAPI standard. The support from tools and generators is terrible; there's still no apparent toolchain that supports version 3.1 fr…

It's kind of insane how stoplight and swagger/smartbear still don't support OpenAPI 3.1

Half tempted to just start building out OA3.1 stuff to replace those services

Post reply on HN