Skip to content

Different serialization behaviour of double values depending on the repository type

The serialization behaviour of double values differs depending on the RepositoryConnection used. In-Memory and HTTPRepository return double values as decimal numbers, while SPARQLRepository returns double values in scientific notation.

For a given LogisticsObject, e.g.

{
    "@context": {
        "@vocab": "https://onerecord.iata.org/ns/cargo#"
    },
    "@type": "Shipment",
    "totalGrossWeight": {
        "@type": "Value",
        "value": {
            "@type": "http://www.w3.org/2001/XMLSchema#double",
            "@value": "10000.0"
        },
        "unit": {
            "@id": "https://onerecord.iata.org/ns/coreCodeLists#MeasurementUnitCode_KGM"
        }
    }
}

With REPOSITORY_TYPE=in-memory, the following is returned:

[
    {
        "@id": "http://localhost:8080/logistics-objects/51daf2f8-2052-4ae0-bbdf-dc7584e5b731",
        "@type": [
            "https://onerecord.iata.org/ns/cargo#Shipment"
        ],
        "https://onerecord.iata.org/ns/cargo#totalGrossWeight": [
            {
                "@id": "neone:0f4948c4-0a51-4843-b928-0656c01ebdcf"
            }
        ]
    },
    {
        "@id": "neone:0f4948c4-0a51-4843-b928-0656c01ebdcf",
        "@type": [
            "https://onerecord.iata.org/ns/cargo#Value"
        ],
        "https://onerecord.iata.org/ns/cargo#unit": [
            {
                "@id": "https://onerecord.iata.org/ns/coreCodeLists#MeasurementUnitCode_KGM"
            }
        ],
        "https://onerecord.iata.org/ns/cargo#value": [
            {
                "@type": "http://www.w3.org/2001/XMLSchema#double",
                "@value": "10000.0"
            }
        ]
    }
]

With REPOSITORY_TYPE=http, the following is returned:

[
    {
        "@id": "http://localhost:8080/logistics-objects/39c5dad8-f7f9-41cd-9066-6ddba2032a9c",
        "@type": [
            "https://onerecord.iata.org/ns/cargo#Shipment"
        ],
        "https://onerecord.iata.org/ns/cargo#totalGrossWeight": [
            {
                "@id": "neone:b0523db7-577d-4b12-a2c7-26918e24043e"
            }
        ]
    },
    {
        "@id": "neone:b0523db7-577d-4b12-a2c7-26918e24043e",
        "@type": [
            "https://onerecord.iata.org/ns/cargo#Value"
        ],
        "https://onerecord.iata.org/ns/cargo#unit": [
            {
                "@id": "https://onerecord.iata.org/ns/coreCodeLists#MeasurementUnitCode_KGM"
            }
        ],
        "https://onerecord.iata.org/ns/cargo#value": [
            {
                "@type": "http://www.w3.org/2001/XMLSchema#double",
                "@value": "10000.0"
            }
        ]
    }
]

With REPOSITORY_TYPE=sparql, the following is returned:

[
    {
        "@id": "http://localhost:8080/logistics-objects/6a5ff0ef-422a-4e10-b1d9-ca311ef42496",
        "@type": [
            "https://onerecord.iata.org/ns/cargo#Shipment"
        ],
        "https://onerecord.iata.org/ns/cargo#totalGrossWeight": [
            {
                "@id": "neone:8dfa489e-5a76-4589-87f4-6436ad929d0a"
            }
        ]
    },
    {
        "@id": "neone:8dfa489e-5a76-4589-87f4-6436ad929d0a",
        "@type": [
            "https://onerecord.iata.org/ns/cargo#Value"
        ],
        "https://onerecord.iata.org/ns/cargo#unit": [
            {
                "@id": "https://onerecord.iata.org/ns/coreCodeLists#MeasurementUnitCode_KGM"
            }
        ],
        "https://onerecord.iata.org/ns/cargo#value": [
            {
                "@type": "http://www.w3.org/2001/XMLSchema#double",
                "@value": "1.0E4"
            }
        ]
    }
]

Tested with RDF4J Server and GraphDB as RDF database backends.