[ https://issues.apache.org/jira/browse/JENA-632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16398449#comment-16398449 ]
ASF GitHub Bot commented on JENA-632: ------------------------------------- Github user kinow commented on the issue: https://github.com/apache/jena/pull/114 +1 for the current draft I would use it [here](https://github.com/kinow/jena/blob/a948f300fb40701e49e83db9d03e5d83da8145f6/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java#L358 and [here](https://github.com/kinow/jena/blob/a948f300fb40701e49e83db9d03e5d83da8145f6/jena-arq/src/main/java/org/apache/jena/sparql/engine/JsonIterator.java#L71). This way instead of looking only at the literals, we'd have the output from the table above. So far I have just two unit tests in my working copy ```java @Test public void testExecJson() { // JENA-632 Query query = QueryFactory.create("JSON { \"s\": ?s , \"p\": ?p , \"o\" : ?o } " + "WHERE { ?s ?p ?o }", Syntax.syntaxARQ); try ( QueryExecution qexec = QueryExecutionFactory.create(query, m) ) { JsonArray jsonArray = qexec.execJson(); assertNotNull( jsonArray ); assertEquals(3, jsonArray.size()); } } @Test public void testExecJsonItems() { // JENA-632 Model model = ModelFactory.createDefaultModel(); { Resource r = model.createResource(AnonId.create("s")); Property p = model.getProperty(""); RDFNode node = ResourceFactory.createTypedLiteral("123", XSDDatatype.XSDdecimal); model.add(r, p, node); r = model.createResource(AnonId.create("s")); p = model.getProperty(""); node = ResourceFactory.createTypedLiteral("abc", XSDDatatype.XSDstring); model.add(r, p, node); r = model.createResource(AnonId.create("s")); p = model.getProperty(""); node = ResourceFactory.createLangLiteral("def", "en"); model.add(r, p, node); } Query query = QueryFactory.create("JSON { \"s\": ?s , \"p\": ?p , \"o\" : ?o } " + "WHERE { ?s ?p ?o }", Syntax.syntaxARQ); try ( QueryExecution qexec = QueryExecutionFactory.create(query, model) ) { Iterator<JsonObject> execJsonItems = qexec.execJsonItems(); while(execJsonItems.hasNext()) { JsonObject next = execJsonItems.next(); System.out.println(next); } } ``` Where the second test is doing - more or less - the same example you provided in your previous comment. Once we have the conversion in place, I will update it to confirm I get what's expected. Then after that I was thinking about quickly running with jacoco to see how much of this PR is being tested. > Generate JSON from SPARQL directly. > ----------------------------------- > > Key: JENA-632 > URL: https://issues.apache.org/jira/browse/JENA-632 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ, Fuseki > Reporter: Andy Seaborne > Assignee: Bruno P. Kinoshita > Priority: Minor > Labels: java, javacc > Time Spent: 0.5h > Remaining Estimate: 0h > > The capability to generate JSON directly from a SPARQL (or extended SPARQL) > query would enable the creation of JSON data API over published linked data. > This project would cover: > # Design and publication of a design. > # Refinement of design based on community feed > # Implementation, including testing. > # Refinement of implementation based on community feed > Skills required: Java, some parser work, design and discussion with the user > community, basic understanding of HTTP and content negotiation. -- This message was sent by Atlassian JIRA (v7.6.3#76005)