Skip to content
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

JSON values #91

Open
pfps opened this issue Sep 19, 2023 · 11 comments
Open

JSON values #91

pfps opened this issue Sep 19, 2023 · 11 comments

Comments

@pfps
Copy link
Contributor

pfps commented Sep 19, 2023

With rdf:JSON there are now JSON values. But what is a JSON value?

For example, in SPARQL should

"7"^^rdf:JSON = 7

be true or false?

@afs
Copy link
Contributor

afs commented Sep 19, 2023

Good question.

It's type error. The dispatches are based on datatype.

Other points:

XSD does not define a type conversion from rdf:JSON in the same way it does for xsd:integer to xsd:double.

xsd:double is "patterned after IEEE 754-2008", and has been made to "mirror IEEE 754-2008", but XSD 1.1 does not say the value space "is" IEEE 754.

You could ask about booleans where the value space (all defs) is true and false.

@pfps
Copy link
Contributor Author

pfps commented Sep 19, 2023

How did xsd:double get in here?

@pfps
Copy link
Contributor Author

pfps commented Sep 19, 2023

How about

' "7" '^^rdf:JSON = "7"

@gkellogg
Copy link
Member

I think it's the same point here, there is no defined way to compare rdf:JSON literals with xsd:string.

@afs
Copy link
Contributor

afs commented Sep 19, 2023

How did xsd:double get in here?

F&O defines operations on numerics by applying subtype substitution and numeric type promotion.

(double, integer) becomes (double, double).

JSON numbers are IEEE 754 , xsd:double are related to IEEE 754.

@pfps
Copy link
Contributor Author

pfps commented Sep 19, 2023

@gkellogg But isn't the value of ' "7" '^^rdf:JSON a string?

@pfps
Copy link
Contributor Author

pfps commented Sep 19, 2023

@afs But isn't the value of "7"^^rdf:JSON just a number, not an IEEE floating point number?

@gkellogg
Copy link
Member

@gkellogg But isn't the value of ' "7" '^^rdf:JSON a string?

Is an INFRA/ECMAScript string the same as an XSD string? At a certain level, but where is that defined? Is a JSON number the same as an xsd:float/double? Or boolean?

I'm note sure we need to define comparison between JSON values and any other.

@afs
Copy link
Contributor

afs commented Sep 20, 2023

These one line comments without background leaving a lot open as to what the point being made actually is.

But isn't the value of "7"^^rdf:JSON just a number,

JSON number value is "corresponding" -- https://tc39.es/ecma262/#sec-terms-and-definitions-number-value

@afs
Copy link
Contributor

afs commented Sep 20, 2023

Just because two values space contain e.g. strings does not mean they are comparable for two reasons:

1:
The value space is the range of the datatype mapping function.

https://www.w3.org/TR/xmlschema11-2/#value-space

The value space of a datatype is the set of values for that datatype.
...
The relations of identity and equality are required for each value space.

RDF Semantics:

The value space of a datatype is the range of the [lexical-to-value mapping](https://www.w3.org/TR/rdf12-concepts/#dfn-lexical-> to-value-mapping).

"The range" is specific to the datatype.

2:
This is reflected in how operators are mapped to (XQuery/XPath) functions.

Operators are matched to functions, in SPARQL, by dispatch, and the functions are datatype specific.
There is no assumption that the two sets of values of unrelated datatypes can be compared for = which is equality by datatype.

JSON-LD makes this clear:

Despite being defined as a set of strings, this value space is considered distinct from the value space of xsd:string, in order to avoid side effects with existing specifications.

@afs
Copy link
Contributor

afs commented Sep 20, 2023

Is an INFRA/ECMAScript string the same as an XSD string?

No - https://tc39.es/ecma262/#sec-terms-and-definitions-string-value are encoding in UTF-16.

xsd:strings are characters, after decoding.

Infra:

The Infra Standard aims to define the fundamental concepts upon which standards are built.

should be read as specific to whatwg.

JSON Numbers are binary patterns of IEEE 754, not rational numbers - encoding vs abstract value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants