Open VladimirAlexiev opened 3 weeks ago
Does this example not show that we "must" allow for both?
My understanding is: The JSON-LD standard specifies that datatype declarations can be used to define the type of literal values, such as integers, dates, or custom data types, by adding a "@type" key within the context or within each value. This is optional in JSON-LD, as JSON-LD tries to be flexible with datatypes to accommodate varied data structures and maximize compatibility with JSON.
From this we have the following option:
As we have the context as part of the profile I do not see that we have to require it (1). However, interoperability is fundamental so that is pointing to requiring it. For me I would recommend (3) - Allowing both.
Virtuoso behaviours is generally not accepted. However, I think we have in CIM standard defined some tolerance that this would be inside.
(split off from https://github.com/Sveino/Inst4CIM-KG/issues/49)
I wrote in https://github.com/3lbits/CIM4NoUtility/issues/278 about the dangers of JSON numbers. JSON doesn't define its numbers:
https://json-ld.org/playground/
1) Convert this to NQuads :
The result is
"0.123"^^xsd:double
and"1"^^xsd:integer
. So depending on the specific value, it's treated as different datatype!2) Only if we add specific datatypes (in the context):
We get what we want:
"1.234567890123457E-1"^^xsd:float
and"1"^^xsd:float
. But 1.234567890123457E-1 has too many decimals for a float. What happened is that internally it was processed as double, and only spit out withfloat
datatype.3) More importantly, you cannot control whether to enclose numbers in quotes on output. I made tests with some tools (I'll commit the details to git):
@value
in quotes and always attach a datatype@value
without quotes (and adds some fake decimal digits due to internal conversions)@value
in quotes with datatype, but the boolean without quotesNote: in all cases we didn't specify a context to use (because it's not ready). If we do, then more tools may output values in quotes.
What is the harm if JSON numbers are enclosed in quotes?