diff --git a/.gitignore b/.gitignore index 2c28b57d..fafe4eeb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ -# Support JetBrains IDEs -.idea +# JetBrains IDEs +.idea/ + +# pyenv version file +.python-version diff --git a/index.html b/index.html index c966d7fb..a440f6ef 100644 --- a/index.html +++ b/index.html @@ -5456,6 +5456,12 @@

Algorithm

  • Initialize converted value to value.
  • Initialize type to null
  • If useNativeTypes is true +
    + Candidate Correction 5 +

    This changes behavior when using native numbers where useNativeTypes is `true`. + For more information, refer to issue 555. +

    +
    1. If the datatype IRI @@ -5477,10 +5483,31 @@

      Algorithm

      xsd:double and its lexical form is a valid xsd:integer or xsd:double - according [[XMLSCHEMA11-2]], set converted value - to the result of converting the - lexical form - to a JSON number.
    2. + according to [[XMLSCHEMA11-2]], + set converted value + to the result of converting the + lexical form + to a JSON number. + : +
        +
      1. + Attempt to convert the lexical form to a JSON number + according to the + [[RFC8785]] + JSON Serialization Scheme (JCS) 3.2.2.3 Serialization of Numbers + procedure. +
      2. +
      3. + If the conversion is successful, set converted value + to its result. +
      4. +
      5. + Otherwise, set type to datatype IRI + of value. +
      6. +
      +
      +
  • Otherwise, if processing mode is not `json-ld-1.0`, @@ -7056,6 +7083,9 @@

    Change log

    Embedding JSON-LD in HTML Documents [[JSON-LD11]] for treating script elements as a single document, as described in Candidate Correction 4.
  • +
  • 2025-01-25: Correct some corner cases in transforming RDF Number Literals + to JSON numbers when useNativeTypes is `true`, + as described in Candidate Correction 5.
  • 2024-01-25: Change processing step for LoadDocumentCallback to not presume that the content type is for JSON, as described in Candidate Correction 6
  • diff --git a/tests/expand-manifest.html b/tests/expand-manifest.html index 85a273e9..145e21c4 100644 --- a/tests/expand-manifest.html +++ b/tests/expand-manifest.html @@ -941,7 +941,7 @@

    - Test t0041 @language: null resets the default language + Test t0041 @language: null
    @@ -950,7 +950,7 @@

    Type
    jld:PositiveEvaluationTest, jld:ExpandTest
    Purpose
    -
    +
    @language: null resets the default language
    input
    expand/0041-in.jsonld diff --git a/tests/fromRdf-manifest.html b/tests/fromRdf-manifest.html index ca803b4b..1ab97678 100644 --- a/tests/fromRdf-manifest.html +++ b/tests/fromRdf-manifest.html @@ -648,6 +648,34 @@

    +
    + Test t0027 use native types flag with values that cannot be serialized to JSON +
    +
    +
    +
    id
    +
    #t0027
    +
    Type
    +
    jld:PositiveEvaluationTest, jld:FromRDFTest
    +
    Purpose
    +
    useNativeTypes flag being true is disregarded for a value that cannot be serialized into a native JSON value.
    +
    input
    +
    + fromRdf/0027-in.nq +
    +
    expect
    +
    + fromRdf/0027-out.jsonld +
    +
    Options
    +
    +
    +
    useNativeTypes
    +
    true
    +
    +
    +
    +
    Test tdi01 rdfDirection: null with i18n literal with direction and no language
    diff --git a/tests/fromRdf-manifest.jsonld b/tests/fromRdf-manifest.jsonld index 1764a682..689eaf4f 100644 --- a/tests/fromRdf-manifest.jsonld +++ b/tests/fromRdf-manifest.jsonld @@ -195,6 +195,16 @@ "purpose": "Check list generation with rdf:first property and rdf:nil value.", "input": "fromRdf/0026-in.nq", "expect": "fromRdf/0026-out.jsonld" + }, { + "@id": "#t0027", + "@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"], + "name": "use native types flag with values that cannot be serialized to JSON", + "purpose": "useNativeTypes flag being true is disregarded for a value that cannot be serialized into a native JSON value.", + "option": { + "useNativeTypes": true + }, + "input": "fromRdf/0027-in.nq", + "expect": "fromRdf/0027-out.jsonld" }, { "@id": "#tdi01", "@type": [ "jld:PositiveEvaluationTest", "jld:FromRDFTest" ], diff --git a/tests/fromRdf/0027-in.nq b/tests/fromRdf/0027-in.nq new file mode 100644 index 00000000..8336cb89 --- /dev/null +++ b/tests/fromRdf/0027-in.nq @@ -0,0 +1,11 @@ + "true"^^ . + "false"^^ . + + "True"^^ . + "False"^^ . + + "1"^^ . + + "0.1e999999999999999"^^ . + "+INF"^^ . + "-INF"^^ . diff --git a/tests/fromRdf/0027-out.jsonld b/tests/fromRdf/0027-out.jsonld new file mode 100644 index 00000000..f03c97a0 --- /dev/null +++ b/tests/fromRdf/0027-out.jsonld @@ -0,0 +1,56 @@ +{ + "@graph": [ + { + "@id": "http://example.com/boolean-native", + "http://example.com/example": [ + { + "@type": "http://www.w3.org/2001/XMLSchema#boolean", + "@value": true + }, + { + "@type": "http://www.w3.org/2001/XMLSchema#boolean", + "@value": false + } + ] + }, + { + "@id": "http://example.com/boolean-object", + "http://example.com/example": [ + { + "@type": "http://www.w3.org/2001/XMLSchema#boolean", + "@value": "True" + }, + { + "@type": "http://www.w3.org/2001/XMLSchema#boolean", + "@value": "False" + } + ] + }, + { + "@id": "http://example.com/number-native", + "http://example.com/example": [ + { + "@type": "http://www.w3.org/2001/XMLSchema#integer", + "@value": 1 + } + ] + }, + { + "@id": "http://example.com/number-object", + "http://example.com/example": [ + { + "@type": "http://www.w3.org/2001/XMLSchema#double", + "@value": "0.1e999999999999999" + }, + { + "@type": "http://www.w3.org/2001/XMLSchema#double", + "@value": "+INF" + }, + { + "@type": "http://www.w3.org/2001/XMLSchema#double", + "@value": "-INF" + } + ] + } + ] +}