W3C home > Mailing lists > Public > public-linked-json@w3.org > January 2015

Type coercion to native JSON numbers via JSON-LD API?

From: Jindřich Mynarz <mynarzjindrich@gmail.com>
Date: Thu, 15 Jan 2015 17:55:59 +0100
Message-ID: <CAE=8Bu88tnvwu8RvA4GUZiO2i37NKZ8JQm+i_c+e7wzPixfQ6g@mail.gmail.com>
To: public-linked-json@w3.org

is it possible to use JSON-LD API to coerce number-like strings into native
JSON numbers (http://www.w3.org/TR/json-ld/#dfn-number)? The section of the
specification on type coercion (http://www.w3.org/TR/json-ld/#type-coercion)
seems to suggest that this is possible, but so far I haven't realized how.

For example, is it possible to coerce the values of the "age" attribute to
numbers in the following JSON-LD?

  "@context": {
    "@vocab": "http://xmlns.com/foaf/0.1/",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "age": { "@type": "xsd:integer" }
  "age": "42"

Setting a numeric datatype (such as xsd:integer) for the property via @type
in @context doesn't do the job.

Is there a way to go about this?



Received on Thursday, 15 January 2015 16:56:47 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:43 UTC