In the context of a discussion started by @trwnh on improving the JSON-LD
@context for #software:lemmy I want to mention the finding we came to with regards to using data types, proposing that as a best-practice. Dedicating a separate topic for findability.
Best practice: In the JSON-LD
@contextuse XML Schema data types to define JSON-LD value properties.
The JSON-LD 1.1 Data Model specifies:
A JSON-LD value is a typed value, a string (which is interpreted as a typed value with type
xsd:string), a number (numbers with a non-zero fractional part, i.e., the result of a modulo‑1 operation, or which are too large to represent as integers (see Data Round Tripping) in [JSON-LD11-API]), are interpreted as typed values with type
xsd:double, all other numbers are interpreted as typed values with type
false(which are interpreted as typed values with type
xsd:boolean), or a language-tagged string.
Here’s the W3C XML Schema Part 2: Datatypes Second Edition specification. The most used are the Primitive datatypes are :
A number of federated apps, like #software:peertube use(d) schema.org data types instead. One advantage is that schema.org offers a JSON-LD definition (but it is large with 1.4 MB). Disadvantages are:
- W3C standards including all Linked Data standards (and ActivityPub too) use XML Schema Data types.
- There are compatibility issues translating between one and the other, even for
schema:Datethat is more often used.
A mapping for going from schema.org to XML Schema data types hasn’t been created (the unresolved issue closed by a bot):