Andy,

I don't think that helps much. In fact, I think treating ASK result
differently from SELECT breaks some abstractions.

What I mean is that the result data structure normally maps to a media type
and not its query form. That way we can have generic parsers/serializers
that are orthogonal to application logic, for example:

MessageBodyReader<Model>: application/rdf+xml, text/turtle,
application/n-triples...
MessageBodyReader<Dataset>: application/n-quads...
MessageBodyReader<ResultSet>: application/sparql-results+xml,
application/sparql-results+json...

Jena's treatment of ASK result breaks this pattern, because it maps to the
same media types as ResultSet does, but there is no way to parse it as
such. Do you see what I mean?

SPARQLResult does not help, because MessageBodyReader<SPARQLResult> makes
little sense.

Why not have ResultSet.getBoolean() or something?

On Mon, Mar 12, 2018 at 12:17 PM, Andy Seaborne <[email protected]> wrote:

> JSONInput.make(InputStream) -> SPARQLResult
>
>     Andy
>
>
> On 12/03/18 10:13, Martynas Jusevičius wrote:
>
>> Hi Andy,
>>
>> I'm not using QueryExecution here, I'm trying to parse JSON read from HTTP
>> InputStream using ResultSetFactory.fromJSON().
>>
>> Then I want to carry the result set, maybe do some logic based on it, and
>> possibly serialize it back using ResultSetFormatter.
>>
>> Is that not possible with ASK result?
>>
>> On Mon, Mar 12, 2018 at 9:46 AM, Andy Seaborne <[email protected]> wrote:
>>
>>
>>>
>>> On 11/03/18 23:03, Martynas Jusevičius wrote:
>>>
>>> Hi,
>>>>
>>>> I'm getting the following JSON result from an ASK query:
>>>>
>>>>     { "head": {}, "boolean": true }
>>>>
>>>> However, the method that usually works fine, will not parse it from
>>>> InputStream (Jena 3.0.1):
>>>>
>>>>       org.apache.jena.sparql.resultset.ResultSetException: Not a
>>>> ResultSet
>>>> result
>>>> org.apache.jena.sparql.resultset.SPARQLResult.getResultSet(
>>>> SPARQLResult.java:94)
>>>> org.apache.jena.sparql.resultset.JSONInput.fromJSON(JSONInput.java:64)
>>>> org.apache.jena.query.ResultSetFactory.fromJSON(ResultSetFac
>>>> tory.java:331)
>>>>
>>>> I stepped inside the code and I see that JSONObject is parsed fine, but
>>>> afterwards SPARQLResult.resultSet field is not being set for some
>>>> reason.
>>>>
>>>> Any ideas?
>>>>
>>>>
>>> The outcome of an ASK query is a boolean, not a ResultSet.
>>>
>>> See execAsk.
>>>
>>> SPARQLResult is the class for a holder of any SPARQL result type.
>>>
>>>      Andy
>>>
>>>
>>>
>>>> Martynas
>>>>
>>>>
>>>>
>>

Reply via email to