- From: Patrick Golden <ptgolden@email.unc.edu>
- Date: Fri, 3 Aug 2018 19:25:11 -0400
- To: public-json-ld-wg@w3.org
Since JSON-LD is a serialization of RDF, it seems like this would be done through using RDF literal datatypes: https://www.w3.org/TR/rdf11-concepts/#section-Datatypes https://json-ld.org/spec/latest/json-ld/#typed-values The datatypes that are almost always used with RDF are defined in XML Schema. It includes types for long, short, float, double, and more. https://www.w3.org/TR/xmlschema11-2/#ordinary-built-ins For example, if I wanted to say that some parameter has the value of "178", expressed as a short integer, I could produce the JSON-LD: { "@context": { "ex": "http://example.org/#", "xsd": "http://www.w3.org/2001/XMLSchema#" }, "@id": "ex:parameter1", "ex:hasValue": { "@value": "178", "@type": "xsd:short" } } Or, more tersely: { "@context": { "ex": "http://example.org/#", "xsd": "http://www.w3.org/2001/XMLSchema#", "value": { "@id": "ex:hasValue", "@type": "xsd:short" } }, "@id": "ex:parameter1", "value": "178" } Both of which produce the triple: <http://example.org/#parameter1> <http://example.org/#hasValue> "178"^^<http://www.w3.org/2001/XMLSchema#short> . Such triples could then be further validated or constrained using OWL or SHACL. Of course, it depends on what you mean by "simple exchange" and "raw" JSON, since it necessarily relies on having a working RDF stack. That might be simple for some users of JSON-LD, and not so simple for others who are not used to working with RDF. Best, Patrick On 07/30/2018 12:59 PM, Leonard Rosenthol wrote: > Figuring I have the right group of experts here… > > Has anyone done work on extending JSON(-LD) with additional data types – > or more specifically more clarity on the precision of existing types. > For example, declaring that an “integer” is long vs. short or that a > “number” can be represented as a float instead of a double. > > We can see how one could define it with JSON Schema, but that doesn’t > help in simple exchange. > > Any thoughts on this? > > Thanks, > > Leonard > > P.S. Yes, I know that most of the binary flavors of JSON support > extended types, but havent’ seen a solution for “raw” JSON. >
Received on Friday, 3 August 2018 23:25:48 UTC