piprate / json-gold

A JSON-LD processor for Go
Apache License 2.0
259 stars 30 forks source link

ld/rdf: object to rdf fix float to int conversion #51

Closed rikysya closed 3 years ago

rikysya commented 3 years ago

Casting float64 to int causing integer overflow on 32 bit systems for large numbers. Cast to int64 explicitly to make conversion architecture independent.

kazarena commented 3 years ago

@rikysya thank you for the PR. Is there test data I can try it with?

rikysya commented 3 years ago

@kazarena Here is some test document with large number to normalise with following options: Format = "application/n-quads" Algorithm = "URDNA2015"

{
  "@context": {
    "instructions": "http://rdf.data-vocabulary.org/#instructions",
    "step": {
      "@id": "http://rdf.data-vocabulary.org/#step",
      "@type": "xsd:integer"
    },
    "description": "http://rdf.data-vocabulary.org/#description",
    "xsd": "http://www.w3.org/2001/XMLSchema#"
  },
  "instructions": [
    {
      "step": 2505620425799233800,
      "description": "Crush lime juice, mint and sugar together in glass."
    }
  ]
}
rikysya commented 3 years ago

@kazarena Do you need anything else from me to proceed with this PR?

kazarena commented 3 years ago

@rikysya no, thank you. Will test it later today.

kazarena commented 3 years ago

Looks good. Thanks for the PR! Merging now...