You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2022/12/16 15:51:49 UTC

[GitHub] [jena] kinow commented on a diff in pull request #1685: Misc

kinow commented on code in PR #1685:
URL: https://github.com/apache/jena/pull/1685#discussion_r1050903012


##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/QueryExecDataset.java:
##########
@@ -340,23 +337,9 @@ public JsonArray execJson() {
         checkNotClosed();
         if ( !query.isJsonType() )
             throw new QueryExecException("Attempt to get a JSON result from a " + labelForQuery(query) + " query");
-
         startQueryIterator();
-
-        JsonArray jsonArray = new JsonArray();
+        JsonArray jsonArray = JsonResults.results(queryIterator, query.getJsonMapping());

Review Comment:
   :ok_man: 



##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/JsonResults.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.sparql.exec;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import org.apache.jena.atlas.json.JsonArray;
+import org.apache.jena.atlas.json.JsonObject;
+import org.apache.jena.atlas.json.JsonValue;
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.QueryIterator;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.jena.sparql.lib.RDFTerm2Json;
+
+/**
+ * ARQ supports an extension query type:
+ * <pre>
+ *    JSON {
+ *       "x": ?var1 ,
+ *       "y": ?var2
+ *    } WHERE {
+ *       ...
+ *    }
+ * </pre>
+ */
+public class JsonResults {

Review Comment:
   Thank you!! I more or less had an idea of what was missing, but didn't know where to start looking for the right place to fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org