Elaborate on handling of JSON builtin types `integer` and `double`
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 139
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
The spec doesn't describe explicitly enough what happens with JSON builtin types integer and double.
- https://w3c.github.io/json-ld-syntax/#typed-values talks about 64-bit doubles and says "such as" without being exhaustive
- By using a native JSON type such as number, true, or false.
- https://w3c.github.io/json-ld-syntax/#type-coercion talks about converting strings, not numerics
- #335 describes an unpleasant situation where an integer (eg
3instead of"3") cannot be used in URL - this example at the playground produces
ex:pi "3.14E0"^^xsd:double(ok) butex:two "2"^^xsd:integer?!?!?
{"@context":{"@vocab":"http://example.org/"},
"pi": 3.14, "two": 2.0000000000000001}
- remove one decimal zero and you get
ex:two "2.000000000000001E0"^^xsd:doublewhich means the datatype varies with the lexical precision - In contrast, Turtle is consistent:
2.0and2.0000000000000001meanxsd:decimal
@msporny @gkellogg
I think the spec should be more explicit what implicit conversions are applied to JSON builtin types, and give some warnings about the examples above.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the JSON-LD 1.1 sections on typed values and type coercion, then review issue #335 and reproduce the linked playground examples for integer and double values. Clarify the implicit conversions and lexical-precision behavior, add explicit specification text and warnings, and update the examples so the resulting datatypes are unambiguous.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100