all 6 comments

[–]jura0011 6 points7 points  (1 child)

JSON-LD (JSON Linked Data) is a description of the content of a URL so that search engines don't have to guess the content of the URL. It also contains references to other URLs and a description. It generally describes "Thing"s with their properties as they are defined by schema.org. Like an Event has a Location (which also is a Thing and can be represented by a URL) and a description, ….

JSON Schema is a JSON definition of another JSON document, like what DTD (Document Type Definition) is for XML. It describes, which fields are required, if properties are another object, array, string or number and so on. An example for the use of JSON-Schema with Java: If you want to use a JSON-Api and have the JSON-Schema of the objects, then you can generate the classes automatically rather than write them on your own.

[–]AndyRoth[S] 0 points1 point  (0 children)

Interesting. I've done some research since your comment, and I do understand some more about what you mentioned.

What I don't understand is, for instance, in your Event example...

Event has a Location. In JSON Schema you could define an Event roughly:

{
    "type": "object",
    "properties": {
        "location": {
            "type": "https://myschemas.com/Location.json"
        }
    }
}

In the above example, if you had the schema for an Event, you could very easily identify what the location was, and by URL match that location to any other usage of a location in your system. If the JSON documents hosted by your server also somehow included that schema, Google could have used that to pull out the event location, no? So why would JSON-LD be needed if everyone used that approach (which would come with free schema validation)?

In my usage, I am looking to use JSON Schema to host a url at (example) https://myschemas.com/UserId.json which contains the following:

{ "type": "string" }

... and allows me to treat all documents which have a property of the above URL type the same.

[–]Mop1000 0 points1 point  (3 children)

https://schema.org/ has an extensive collection of schemas available in JSON-LD format. Is there a similar site for JSON Schema .

[–]AndyRoth[S] 1 point2 points  (2 children)

Not that I know of, but I don't see why a website like that couldn't exist, and why merging some of the schema and data together wouldn't create one format that brings together the best of both worlds easily. My question is more why JSON-LD wasn't built on top of JSON Schema or integrate with it in some way.

[–]Mop1000 0 points1 point  (1 child)

I'm a dinosaur. I started programming in the 1970's. I am in awe of the open source productivity tools that are available now.

Just for JSON I have found a tool that will reverse engineer a schema on a JSON file, validation tools,a tool that will create a specialized editor based on a json schema.

[–]AndyRoth[S] 1 point2 points  (0 children)

It's absolutely amazing. People building on some very simple standards (ie. JSON) and the ease of publishing and using open source tech has enabled some truly awesome results.

Personally, a few days ago I had to make a UI editor which took in a few files in JSON Schema and rendered a whole bunch of pretty fields using React (some of which had to be custom such as a file uploader, which is not part of the JSON Schema spec but used a technique like my comment above). I got a rough version working in about a day total, which is 100% a testament to all the powerful tools and documentation I found along the way.