-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement feedback #6
Comments
I deleted the My [understanding] of [understanding]:
|
Doh, good spot! Thanks |
Regarding {
"type": "object",
"properties": {
"foo": { "type": "string" },
"bar": { "type": "number" }
}
} In this example, the value at {
"type": "object",
"properties": {
"$comment": { "type": "string" },
"foo": { "type": "string" },
"bar": { "type": "number" }
}
} Here, "$comment" is not a comment, it's a just a property name. So, when I say that |
Thanks again for your help! |
Hi @jdesrosiers, Sorry to necro this Can you foresee a problem with this method? Before: {
"$schema": "http://json-schema.org/draft-07/schema#",
"alias": {
"s": "http://schema.org"
},
"definitions": {
"disambiguatingDescription": {
"$id": "#disambiguatingDescription",
"s:additionalType": "http://schema.org/Text",
"s:sameAs": "http://schema.org/disambiguatingDescription",
"type": "string"
} [...] After: {
"$schema": "http://json-schema.org/draft-07/schema#",
"alias": {
"s": "http://schema.org"
},
"definitions": {
"disambiguatingDescription": {
"$id": "#disambiguatingDescription",
"s:additionalType": "s:Text",
"s:sameAs": "s:disambiguatingDescription",
"type": "string"
} [...] Hope to hear back Sincerely |
Seems reasonable to me. I don't see any issues. |
Hi @jdesrosiers, Hope you're well Is there any documentation for this alias technique - correct me if I'm wrong but I vaguely recall you said you "made it up"?:
Example, for the after code block above would both of these be correct?:
Hope to hear back Sincerely |
Yep, we made it up, so you can define it to do whatever you want. It was inspired by how aliasing works in JSON-LD, so I'd suggest that you do whatever JSON-LD is doing. I'm pretty sure it uses standard URI resolution, but it's possible that it uses string concatenation. You'll have to look up the documentation to be sure. |
Yes, JSON-LD compact IRIs is nice; tersely illustrates keyword and type (just working my way through this spec' but it's pretty dense 😔) Presuming the vocabulary has all keywords I need, I'm now left wondering why I should even use JSON Schema..? I always (naively, not knowing JSON-LD fully) evaluated based on whether I need it on the web (i.e. to link data)?:
... but I wonder how you evaluate? Can I combine JSON Schema and JSON-LD? For instance, I haven't seen anything in the JSON-LD spec' yet that allows me to combine schemas conditionally like in JSON Schema Hope to hear back Sincerely |
What are you trying to accomplish?
This doesn't make sense. JSON Schema and JSON-LD are not alternatives. They do very different things. If you need to validate the structure of JSON data, then JSON Schema is what you need. You can't validate JSON with JSON-LD. If you need to assign semantics to your data, then JSON-LD is what you need. You can't assign semantics to data with JSON Schema.
I'm not entirely sure what that means. Can you validate a JSON-LD document with JSON Schema? No, JSON-LD doesn't have a single fixed structure, so validating it's structure with JSON Schema would be inconclusive. However, you can validate a JSON document with JSON Schema and then apply a JSON-LD context to the JSON document to get a JSON-LD document. Can you define semantics and validation constraints in the same document? Not without inventing a JSON Schema vocabulary as we have done here. If you do this, however, you can't expect tools to automatically understand what you've invented. You'll have to write your own tooling to make use of the thing you invented. I can imagine an application needing both JSON-LD and JSON Schema, but not at the same time. You might need one in one context and another in another context. I'd have to know more about what you are trying to do to advise which to use. But, I suspect there is some fundamental misunderstanding at play that is the cause of the confusion. |
I read a bit more of the JSON-LD spec' yesterday so I'm a little clearer on what it does...
A logical process/workflow that comprises structure validation AND semantic validation really 🎯 This is the explanation I was looking for; practically how to go from a JSON Schema document to a JSON-LD document:
Sincerely |
I'm afraid this doesn't clear anything up for me. A process/workflow for what? Are you developing a static website, a web app, an API, something else? All of these things and more will factor into what you choose. What does "semantic validation" mean?
There might be some confusion here. You can't go from a JSON Schema to a JSON-LD document. If you start with a plain JSON document you have two paths you can take. One involves JSON Schema and the other involves JSON-LD.
You can't do this: In theory, if you invent a JSON Schema vocabulary for linked data, let's call it "JSON-LD Schema" you could do
But, I'm fairly certain that not even inventing a vocabulary will allow you to do this: |
FWIW, I don't think this is legal in json schema (anchor names are referenced with
|
@karenetheridge |
Yes, I saw |
A context-agnostic JSON data structuring process/workflow I often create data structures simply to make sense of data (e.g. query, sort) so JSON Schema is useful because I can use tools to validate data structures. To date this is what I've been doing but I see some features in JSON-LD that I'd like to use (e.g. aliasing) for semantic validation (i.e. vocabulary, type, keyword). I don't know any tools to help automate semantic validation but I can reference type and keywords manually using this alias technique so first and foremost it's useful for my future self.
None of the above (yet), but I may want to use my data in (one of) these contexts later
I infer "semantic validation" is validating keywords are part of an object's type but please correct me if I'm wrong (I suspect you may be referring to JSON-LD syntax tokens and keywords, which I suppose could be automated) I'm now clear JSON Schema and JSON-LD are mutually exclusive I guess a better question would be: if I'm using JSON Schema when should I involve JSON-LD? Sincerely |
I'm not sure that makes sense. JSON-LD gives meaning to data. Asserting that properties are part of an object's type sounds like structural validation. An object is a structure.
Let's say you want to aggregate several databases with information about people. All of these databases store names in different ways. One might use So, I would get JSON-LD involved if you expect a third party to be able understand your data without having to coordinate with you about your internal data model. A real life example is web crawlers. If they find JSON-LD on your web page, they can use that information to better index your site and provide more effective search results. |
Yes, your point makes (more) sense JSON Schema for structural validation and JSON-LD for semantic validation helps clarify things Aside, I'm looking at creating some data instances from this repo's data schema using JSON-LD - practically how would one go about doing that?:
I guess Unsure about Sincerely NB I did see this:
|
The concept of "validating semantics" still sounds like nonsense to me. Semantics are arbitrary. Some blob of data represents a book because I say it represents a book. What would a semantic validator do? Would it tell me, "Actually, that data doesn't represent a book, it's more of a pamphlet."? No, it's a book because I decided it is to be understood to be a book. You need to decouple any concept of validation (semantic or otherwise) from JSON-LD. That's just not what it's for.
Like I said, I don't think this is possible. The good news is it's also unnecessary because you've already validated the structure in step 2. You don't need to do it again. Your data didn't change because you added a I probably shouldn't bring up something new at this point, but you might be interested in SHACL (https://shacl.org/playground/). SHACL is kinda like JSON Schema for RDF. Since JSON-LD is just a JSON serialization of RDF, you can use SHACL to validate JSON-LD documents. So your process would be:
If you really want/need JSON-LD, this might be a more integrated workflow. The downside is that SHACL is relatively new and not widely adopted. You'll have difficulty finding tools and the learning curve will likely be steep. I personally don't know SHACL beyond the high level description I've given you here, so I can't comment on it's capabilities compared to JSON Schema. It might suit your needs and it might not. |
Erm, validate that
Sorry, I now see that mostly everything in JSON-LD is a string (haven't got this far in the spec' yet 🤭) and presume, as you say, that validating this type of thing (i.e. semantics) isn't the job of JSON-LD; it's the job of JSON Schema (i.e. structure)
LOL Sincerely |
Hi @jdesrosiers!
Thanks for feedback - very kind
I've deleted the gist and migrated it to this repo, which I created the other day - it's almost identical to the gist with the exception of some bits unrelated to your feedback
I'll implement your feedback in a commit shortly and hope you'd be kind enough to glance at it again so I can resolve this issue
Sincerely
The text was updated successfully, but these errors were encountered: