GithubHelp home page GithubHelp logo

pkdevbox / construct-json-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from garlik/construct-json-php

0.0 3.0 0.0 104 KB

Implementation of SPARQL CONSTRUCT JSON in PHP

License: GNU General Public License v3.0

HTML 7.99% PHP 92.01%

construct-json-php's Introduction

This is a simple implementation of the CONSTRUCT JSON idea
(http://steveharris.tumblr.com/post/4590579712/construct-json).

To install this code first edit settings.php to state what endpoint you with to
use, then copy settings.php, query.php, and sparql-xml-parse.php to an
appropriate place in your Apache deployment. You can also copy the index.html
if you want a simple HTML frontpage.

An example query is:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
CONSTRUCT JSON {
   { "name": ?name, "sha1": ?sum }
}
FROM <http://plugin.org.uk/swh.xrdf>
WHERE {
   ?x foaf:name ?name .
   OPTIONAL {
      ?x foaf:mbox_sha1sum ?sum .
   }
}
LIMIT 10

Which when rul will produce the following results:

[
    {
        "name": "Libby Miller",
        "sha1": "289d4d44325d0b0218edc856c8c3904fa3fd2875" 
    },
    {
        "name": "Luke Wilson-Mawer",
        "sha1": "cdd70a4226b1b980e49b6e3a85471ac4d94d7483" 
    },
    {
        "name": "Andy Thomas",
        "sha1": "e82619232f833cd68c388dcb1ffe00af52e0f91c" 
    },
    {
        "name": "Dave Beckett",
        "sha1": "970987f991961f2553a1bf2574166fa29befbccb" 
    },
    {
        "name": "JXT",
        "sha1": NULL 
    },
    {
        "name": "Nick Gibbins",
        "sha1": "08d333c6437a2411f18a29b49e5a6a07649c9bf1" 
    },
    {
        "name": "Jamin",
        "sha1": NULL 
    },
    {
        "name": "Mischa Tuffield",
        "sha1": "13dbc4ea7e4fc55ae706562a14ab5b444f805d8c" 
    },
    {
        "name": "Nigel Shadbolt",
        "sha1": "e966302104bd52f060f0e4545e8299f2d54ee3ae" 
    },
    {
        "name": "LV2",
        "sha1": NULL 
    }
]

?var subsitutions will happen anywhere in the JSON section, including inside
strings (probably a bug), and on the key side of key/value pairs, so you can do things like:

{ "name": ?name, ?type: ?value }

The code is made available under the GPL v3, see COPYING for details.

construct-json-php's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.