W3C home > Mailing lists > Public > public-linked-json@w3.org > March 2013

Re: Node.js tool for RDFa -> JSON-LD transformation

From: Niklas Lindström <lindstream@gmail.com>
Date: Sat, 30 Mar 2013 11:27:24 +0100
Message-ID: <CADjV5jehX3t9iHW7da-c_nm9XM6W7+-UnuWTjEzT_HZhorNGeg@mail.gmail.com>
To: Ivan Herman <ivan@w3.org>
Cc: Manu Sporny <msporny@digitalbazaar.com>, JSON-LD CG <public-linked-json@w3.org>
On Sat, Mar 30, 2013 at 10:57 AM, Ivan Herman <ivan@w3.org> wrote:
>
> On Mar 30, 2013, at 03:16 , Niklas Lindström <lindstream@gmail.com> wrote:
>
>> Very cool!
>>
>> As you know, my RDFa implementation in the RDFa-lab (which also runs
>> on Node and in the browser) [1] directly generates expanded JSON-LD.
>> I've then used your jsonld.js (with the framing stuff pruned) on that,
>> e.g. in combination with the Connect algorithm in the lab.
>>
>> Another thing I've used for a while is RDFLib (Python), combined with
>> rdflib-jsonld and the "rdfpipe" commandline tool (from RDFExtras) to
>> do something very similar (rdfpipe can handle most RDF formats in and
>> out):
>>
>>    $ curl -L http://w3id.org/payswarm/v1 -o /tmp/payswarm-v1.jsonld
>>    $ rdfpipe -irdfa http://recipes.payswarm.com/?p=10554
>> -ojson-ld:context=/tmp/payswarm-v1.jsonld
>
> As an aside: do you think it would be possible to add the json-ld serializer into the core RDFLib distribution soon? For the time being, as you know, I use my own json-ld serializer in pyRdfa, but I have not really done anything with it lately, and I am not even sure it is up to date. I would really prefer to rely on a core module...

The plan is definitely to do that as soon as JSON-LD is a REC. You can
install it separately now as well, as it plugs into RDFLib (making
e.g. "rdfpipe" from RDFExtras, also installable separately, pick it
up). Alas, I haven't had time to touch the code since december
though*, so it needs to be updated to the latest behaviour. (Also, the
implementation has hitherto been focused more on getting to/from RDF
than properly implementing full compaction/flattening, etc. An
alternative would be to adapt pyld [1] instead, if that is more up to
date.)

Cheers,
Niklas

[1]: https://github.com/digitalbazaar/pyld

(* I'm in the final days of changing jobs; working parallell in two
consulting assignments (one is the legal info system referenced, which
is a pain to leave behind; the other is the national library system,
which is an inspiring challenge I'll continue with as an employee). So
I've really been "up to my neck in alligators, having a hard time
focusing on draining the swamp". ;])


> Thx.
>
> Ivan
>
>
>>
>> (Something it it goes wrong when fetching the remote context, so I had
>> to use a local copy. Alas, I haven't had time to work on rdflib-jsonld
>> for quite some time now.)
>>
>> And recently (as in 3 hours ago), the Swedish legal information system
>> I built (in Java/Groovy) [2] was updated to use an up-to-date JSON-LD
>> context. This system actually consumes legal information published in
>> RDF/XML or RDFa now (over Atom), and among other things funnel
>> extracted JSON-LD into ElasticSearch. See e.g. [3] and [4] (but note
>> that the new context isn't deployed yet).
>>
>> Cheers,
>> Niklas
>>
>> [1]: https://github.com/niklasl/rdfa-lab
>> [2]: https://github.com/rinfo/rdl/tree/develop
>> [3]: http://rinfo.lagrummet.se/publ/sfs/1736:0123_1/konsolidering/1736-01-23
>> [4]: http://service.lagrummet.se/publ/sfs/1736:0123_1/konsolidering/1736-01-23/data.json
>>
>>
>> On Sat, Mar 30, 2013 at 2:34 AM, Manu Sporny <msporny@digitalbazaar.com> wrote:
>>> bcc: RDFa WG, RDF WG
>>>
>>> Dave Lehn and Dave Longley just put together a tool that's pretty rough
>>> around the edges, but really helpful for those trying to:
>>>
>>> * Transform RDFa to JSON-LD
>>> * Normalize JSON-LD/RDF Datasets to NQuads
>>> * Transform JSON-LD to compact, expanded, normalized, or flattened form
>>>
>>> To install the tool, do the following (you will need git, nodejs, and
>>> npm installed):
>>>
>>> git clone https://github.com/digitalbazaar/jsonld.js.git
>>> cd jsonld.js
>>> npm install
>>>
>>> To compact a document on the Web using a JSON-LD context published on
>>> the Web:
>>>
>>> ./bin/jsonld compact
>>>  -c "http://w3id.org/payswarm/v1"
>>>  "http://recipes.payswarm.com/?p=10554"
>>>
>>> That will read in a PaySwarm Asset and Listing in RDFa 1.0 format (using
>>> Green Turtle by Alex Milowski), convert it to JSON-LD expanded form,
>>> compact it using the 'http://w3id.org/payswarm/v1' context, and dump it
>>> out to the console in compacted form.
>>>
>>> ./bin/jsonld normalize -q "http://recipes.payswarm.com/?p=10554"
>>>
>>> That will read in a PaySwarm Asset and Listing in RDFa 1.0 format,
>>> normalize the data using the RDF Dataset normalization algorithm, and
>>> then dump the output to normalized NQuads format. The NQuads can then be
>>> processed via SHA-256, or similar algorithm, to get a deterministic hash
>>> of the contents of the Dataset.
>>>
>>> The implementation is up-to-date with the RDFa and JSON-LD specs. The
>>> tool still needs quite a bit of tweaking, but it's a pretty powerful
>>> demonstration of many of the things this community has been building
>>> over the past several years.
>>>
>>> -- manu
>>>
>>> --
>>> Manu Sporny (skype: msporny, twitter: manusporny, G+: +Manu Sporny)
>>> Founder/CEO - Digital Bazaar, Inc.
>>> blog: Google Summer of Code 2013: RDFa, JSON-LD, Web Payments
>>> http://digitalbazaar.com/2013/03/12/gsoc/
>>>
>>
>
>
> ----
> Ivan Herman, W3C Semantic Web Activity Lead
> Home: http://www.w3.org/People/Ivan/
> mobile: +31-641044153
> FOAF: http://www.ivan-herman.net/foaf.rdf
>
>
>
>
>
Received on Saturday, 30 March 2013 10:28:23 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:53:21 UTC