Re: Handling integers

Hey Angelo,

Sorry I missed this email back in...May. ;-P

I wondered very similar things, and we discussed them a bit in the JSON-LD WG recently:
https://github.com/w3c/json-ld-bp/issues/14

The ultimate conclusion is that JSON-LD does one thing: encodes a graph in JSON by mapping local names to global names (and wrangling various JSON shapes into graphy ones).

So, essentially type casting of this sort, isn't JSON-LD's job...but a tool that uses the expanded form (for instance) might be able to clean-up data on ingest or generation.

Here's how I summarized it in the issue:
https://github.com/w3c/json-ld-bp/issues/14#issuecomment-532125931

Ultimately we plan to explain that in the forthcoming Best Practices guide. As someone else who's shared this confusion, your input here would be most welcome. :)

Cheers,
Benjamin
Co-Chair, W3C JSON-LD


--

http://bigbluehat.com/

http://linkedin.com/in/benjaminyoung

________________________________
From: Angelo Veltens <angelo.veltens@online.de>
Sent: Friday, May 31, 2019 4:46 AM
To: JSON-LD CG <public-linked-json@w3.org>
Subject: Handling integers

Hi everybody,

Question regarding Integers in JSON-LD.

Given the following snippet:

{
  "@context": {
    "@vocab": "http://vocab.example/"
  },
  "age": {
    "@value": "27",
    "@type": "http://www.w3.org/2001/XMLSchema#integer"
  }
}

Is there a JSON-LD algorithm / context to transform it to a real JSON
integer?

{
  "@context": {
    "@vocab": "http://vocab.example/"
  },
  "age": 27
}

They are semantically the same, but the upper construct is much more
complicated to handle in JavaScript application and does not give any
additional value. I would have expected at least the compact algorithm
to output the latter construct.

All the best,
Angelo

Received on Friday, 4 October 2019 15:41:59 UTC