[cross post from post to GDE-21 attendants]
Hi all,
In a smaller circle we have been discussing the need for JSON output.
Ideally we’d base that on something established. Clingo has JSON output,
which seems close. Unfortunately it simply emits the model as a list of
strings, e.g. “sleeps(bob)”. That works reasonably as long as your model
is ground and doesn’t contain function symbols. It doesn’t work that
nice for s(CASP). In addition, we also have a justification. Joaquin
asked around in the CLP community, but there too was little concrete
input.
So, I decided to give it a try. One starting point was the work on
Pengines, the underlying protocol used by the online version of
SWI-Prolog (SWISH). The term representation thereof has also been used
by MQI, another contributed project providing a Prolog JSON based API.
The SWI-Prolog version of s(CASP) now allows for (use --json=-
for stdout)
scasp --json=file input.pl
If you do not want to install, there is a web service at
s(CASP) web server which you can also use as a service using e.g.
curl --data-binary @test/programs/birds.pl -H "Content-Type: text/x-scasp" -X POST https://dev.swi-prolog.org/scasp/solve
See s(CASP) web server -- help for some more details on the
API. Feel free to hammer it. The server is a 32-core rather old and slow
cloud (virtual) machine that doesn’t do anything critical.
I have not yet made a description of the JSON format. It should be fairly
self-explanatory. Could anyone interested in this have a look and give
feedback so we can settle this?
At the moment it should be able to deal with all s(CASP) terms except for
partial lists.
Regards --- Jan
p.s. For local installation
- Install SWI-Prolog 8.5.1
- git clone https://github.com/JanWielemaker/sCASP.git
- Build scasp using `make`
- Or start the web server as above using (default port 8080)
swipl examples/dyncall/http.pl [-p port]