if you install this: https://github.com/RDFLib/rdflib-jsonld

then you can do this (python 2.7):

>>> from rdflib import Graph
>>> g = Graph()
>>> xml = """<?xml version="1.0"?>
...
... <rdf:RDF
... xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
... xmlns:si="https://www.w3schools.com/rdf/";>
...
... <rdf:Description rdf:about="https://www.w3schools.com";>
...   <si:title>W3Schools</si:title>
...   <si:author>Jan Egil Refsnes</si:author>
... </rdf:Description>
...
... </rdf:RDF>"""
>>> g.parse(data = xml)
<Graph identifier=N5188733317044266a20c3957e8365a76 (<class
'rdflib.graph.Graph'>)>
>>> print g.serialize(format = 'json-ld')
[
  {
    "@id": "https://www.w3schools.com";,
    "https://www.w3schools.com/rdf/author": [
      {
        "@value": "Jan Egil Refsnes"
      }
    ],
    "https://www.w3schools.com/rdf/title": [
      {
        "@value": "W3Schools"
      }
    ]
  }
]
>>>


–– Si vis pacem, bellum adflicta. ––

On Sat, May 20, 2017 at 11:35 AM, <knabhi...@gmail.com> wrote:

> I am unable to convert my rdf xml into json I have looked a lot over
> internet but I am unable to do it can u please tell in detail how to
> convert a large rdf/xml to json objects
>
>
> On Wednesday, March 22, 2017 at 5:21:42 PM UTC+1, maparent wrote:
> > Yes, rdflib can parse RDF (in many formats) and emit various JSON
> formats.
> > I strongly recommend looking at json-ld, which is a very flexible format
> that allows you to express your RDF resources in a variety of json
> structures that are ideally consumable by javascript. Rdflib has a good
> jsonld module.
> > Regards,
> > Marc-Antoine Parent
> >
> > > Le 22 mars 2017 à 12:17, cabuscrea...@gmail.com a écrit :
> > >
> > > Hello
> > > I am working on a project to convert RDF data to JSON, with the goal
> of using it in a web framework.
> > >
> > > I have tried some XML to JS conversion tools, but they never quite
> work on RDF XML, but do on regular XML documents.
> > >
> > > So, for example, I have this:
> > >
> > > <?xml version="1.0"?>
> > > <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
> > > <rdf:Description xmlns:ns1="dc:" rdf:about="http://localhost:
> 8080/cgi-bin/koha/opac-detail.pl?biblionumber=3140">
> > >     <ns1:creator rdf:resource="https://fr.
> wikipedia.org/wiki/Katherine_Paterson"/>
> > > </rdf:Description>
> > > </rdf:RDF>
> > > </xml>
> > >
> > > Which seems to not play nice with, for example, the JQuery parser.
> > >
> > > I am wondering..would this library help me with my goal?
> > >
> > > Thanks so much
> > >
> > > Michael Cabus
> > >
> > > --
> > > http://github.com/RDFLib
> > > ---
> > > You received this message because you are subscribed to the Google
> Groups "rdflib-dev" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an email to rdflib-dev+unsubscr...@googlegroups.com.
> > > To post to this group, send email to rdflib-dev@googlegroups.com.
> > > To view this discussion on the web visit https://groups.google.com/d/
> msgid/rdflib-dev/1d45e649-e2f8-47b9-ab96-fabfd0dac967%40googlegroups.com.
> > > For more options, visit https://groups.google.com/d/optout.
>
> --
> http://github.com/RDFLib
> ---
> You received this message because you are subscribed to the Google Groups
> "rdflib-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rdflib-dev+unsubscr...@googlegroups.com.
> To post to this group, send email to rdflib-dev@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/rdflib-dev/e1ec15a8-103c-47e8-bfde-58c8c8a95416%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
http://github.com/RDFLib
--- 
You received this message because you are subscribed to the Google Groups 
"rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rdflib-dev+unsubscr...@googlegroups.com.
To post to this group, send email to rdflib-dev@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rdflib-dev/CABjEdSfsVWdmxowrpYkVLEF2QEuv1WZS9DY-KG5DXpB8USSEpA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to