On Nov 28, 2017, at 09:12 AM, ivaylo.velitch...@ext.ec.europa.eu wrote:
> 
> JSON is available as result option in the SPARQL endpoint interface, but when 
> configuring a rewrite rule it is missing. Currently SPARQL results options in 
> Virtuoso 07.20.3217 are only "Automatic", "RDF/XML" and "Turtle".
>  
> How to configure the rule to give the results in JSON?
>  
> (I’ve asked this also in Stack Overflow 
> <https://stackoverflow.com/questions/47460148/how-to-configure-virtuoso-url-rewrite-rule-to-give-sparql-results-in-json>
>  but nobody answered so far. 
>  
> Thanks!
>  
> Ivo


As answered in reply to your direct email to OpenLink Support,
and on the Stack Overflow post --

This was an oversight in the Conductor interface, as the SPARQL query results 
can be returned in any of the serialization formats available from the 
`/sparql` Query Form page, which includes JSON. We have logged an internal 
enhancement request to have these additional formats added to the Conductor URL 
Rewrite Rule UI.

In the meantime, you can export an existing rule through the link in the 
Conductor UI, to see the SQL that is used to create the selected rule. For the 
default RDF/XML output format, it is presented as 
`format=application%2Frdf%2Bxml`.

Working from [the list of supported output formats][1], you should be able to 
change the `format=application%2Frdf%2Bxml` in the exported rule to something 
like `format=application%2Frdf%2Bjson` to get your desired JSON output. You can 
then manually load the edited rule via `isql`, which will look something like:

    DB.DBA.VHOST_REMOVE (
        lhost=>'*ini*',
        vhost=>'*ini*',
        lpath=>'/rewrite-json'
    );
    
    DB.DBA.VHOST_DEFINE (
        lhost=>'*ini*',
        vhost=>'*ini*',
        lpath=>'/rewrite-json',
        ppath=>'/',
        is_dav=>0,
        is_brws=>0,
        def_page=>'',
        vsp_user=>'dba',
        ses_vars=>0,
        opts=>vector ('browse_sheet', '', 'url_rewrite', 'http_rule_list_1'),
        is_default_host=>0
    );
    
    DB.DBA.URLREWRITE_CREATE_RULELIST ( 
        'http_rule_list_1', 1,
        vector ('http_rule_1')
    );
    
    DB.DBA.URLREWRITE_CREATE_REGEX_RULE ( 
        'http_rule_1', 1,
        '/rewrite-json',
        vector (),
        0,
        
'/sparql?query=select%%20%%2A%%20where%%20%%7B%%3Fs%%20%%3Fp%%20%%3Fo%%7D%%20limit%%205&format=application%2Frdf%2Bjson',
        vector (),
        NULL,
        NULL,
        2,
        301,
        ''
    );

***Note:** you will not be able to edit this rewrite rule in the Conductor 
until this issue is fixed therein, as the JSON output format will be 
over-written with one of those in the current list.*


  [1]: http://docs.openlinksw.com/virtuoso/rdfsparqlprotocolendpoint/



--
A: Yes.                          http://www.idallen.com/topposting.html
| Q: Are you sure?           
| | A: Because it reverses the logical flow of conversation.
| | | Q: Why is top posting frowned upon?

Ted Thibodeau, Jr.           //               voice +1-781-273-0900 x32
Senior Support & Evangelism  //        mailto:tthibod...@openlinksw.com
                             //              http://twitter.com/TallTed
OpenLink Software, Inc.      //              http://www.openlinksw.com/
         10 Burlington Mall Road, Suite 265, Burlington MA 01803
     Weblog   -- http://www.openlinksw.com/blogs/
     LinkedIn -- http://www.linkedin.com/company/openlink-software/
     Twitter  -- http://twitter.com/OpenLink
     Google+  -- http://plus.google.com/100570109519069333827/
     Facebook -- http://www.facebook.com/OpenLinkSoftware
Universal Data Access, Integration, and Management Technology Providers








Attachment: smime.p7s
Description: S/MIME cryptographic signature

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Virtuoso-users mailing list
Virtuoso-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/virtuoso-users

Reply via email to