W3C home > Mailing lists > Public > public-rdf-wg@w3.org > January 2013

JSON-LD grammar

From: Markus Lanthaler <markus.lanthaler@gmx.net>
Date: Fri, 4 Jan 2013 18:51:44 +0100
To: <public-linked-json@w3.org>
Cc: "'RDF WG'" <public-rdf-wg@w3.org>
Message-ID: <018c01cdeaa4$29bc6100$7d352300$@lanthaler@gmx.net>
As announced in the last mail, I've just fixed the last remaining issues in
the JSON-LD Grammar section. It definitely does the job, I was just
wondering whether we should also include a more formal, ABNF-like grammar
(or maybe even replace the prose). Unfortunately it seems that currently
there's no accepted way or best-practice to specify JSON "grammars" (the
JSON Schema Internet Draft expired two years ago [1]).

So I tried to come up with something ABNF-like (it's not valid ABNF) and
would be interested in hearing your opinions. I'm not sure myself yet
whether that helps or confuses people.

graph = node-obj / node-obj[]

node-obj =
    {
        "@context": context-def       (0..1)
        "@id": string                 (0..1)
        "@type": iri / iri[]          (0..1)
        "@graph": graph               (0..1)
        "@annotation": string         (0..1)
        property-key: property-value / property-value[] /
                      language-map / annotation-map  (*)
    }

value-obj =
    {
        "@context": context-def    (0..1)
        "@value": scalar           (0..1)
        "@language": bcp47-tag / "@type": iri    (0..1)
        "@annotation": string
     }

list-obj =
    {
        "@context": context-def       (0..1)
        "@list": list-set-value / list-set-value[]  (1)
        "@annotation": string         (0..1)
    }

set-obj =
    {
        "@context": context-def       (0..1)
        "@set": list-set-value / list-set-value[]  (1)
        "@annotation": string         (0..1)
    }

language-map =
    {
        "@context": context-def       (0..1)
        bcp47-tag: string / string[]  (*)
    }

annotation-map =
    {
        "@context": context-def       (0..1)
        string: property-value / property-value[]   (*)
    }

list-set-value = scalar / node-obj / value-obj

property-value = list-set-value / list-obj / set-obj

context-def = null / iri / context-def-obj /
              (null / iri / context-def-obj)[]

context-def-obj =
    {
        property-key: null / iri / term-def-obj   (*)
        "@language": bcp47-tag      (0..1)
        "@vocab": iri               (0..1)
    }

term-def-obj =
    {
        "@id": iri    (0..1)
        "@language": bcp47-tag / "@type": iri    (0..1)
        "@container": ( "@list" / "@set" / 
                        "@language" / "@annotation" )   (0..1)
    }

bcp47-tag = string   ; should this be more explicit?

iri = string         ; should this be more explicit?

property-key = string - keyword  ; any string except a keyword

keyword = @context / @id / @value / @language / @type /
          @container / @list / @set / @annotation / @vocab / @graph

scalar = null / string / number / true / false



[1] http://tools.ietf.org/html/draft-zyp-json-schema-03


Cheers,
Markus



--
Markus Lanthaler
@markuslanthaler
Received on Friday, 4 January 2013 17:52:12 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:25:53 GMT