[ 
https://issues.apache.org/jira/browse/JENA-632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16442351#comment-16442351
 ] 

ASF GitHub Bot commented on JENA-632:
-------------------------------------

Github user kinow commented on a diff in the pull request:

    https://github.com/apache/jena/pull/114#discussion_r182394976
  
    --- Diff: jena-arq/Grammar/master.jj ---
    @@ -2176,6 +2251,19 @@ String String() : { Token t ; String lex ; }
         }
     }
     
    +#ifdef ARQ
    +Number Number() : { Token t ; Number number ; }
    +{
    +  (
    +    t = < INTEGER > { number = integerValue(t.image) ; }
    +  | t = < DECIMAL > { number = doubleValue(t.image) ; }
    --- End diff --
    
    Oh! It was by accident that it got fixed I think?
    
    I copied parts of the `SelectClause()` to `JsonClause()`. More 
especifically, the Select had:
    
    ```
          // Expressions without ()
          ( LOOKAHEAD(2)
            expr = BuiltInCall()        { getQuery().addResultVar((Var)null, 
expr) ; }
          | expr = FunctionCall()       { getQuery().addResultVar((Var)null, 
expr) ; }
          | n = RDFLiteral()            { getQuery().addResultVar((Var)null, 
NodeValue.makeNode(n)) ; }
          | n = NumericLiteral()        { getQuery().addResultVar((Var)null, 
NodeValue.makeNode(n)) ; }
          | n = BooleanLiteral()        { getQuery().addResultVar((Var)null, 
NodeValue.makeNode(n)) ; }
    ```
    
    Which became the following for the JSON counterpart:
    
    ```
        o = Var() { getQuery().addResultVar((Var)o) ; 
getQuery().addJsonMapping(s, o) ; }
      | o = RDFLiteral() { getQuery().addResultVar(s, NodeValue.makeNode(o)) ; 
getQuery().addJsonMapping(s, o) ; }
      | o = NumericLiteral() { getQuery().addResultVar(s, 
NodeValue.makeNode(o)) ; getQuery().addJsonMapping(s, o) ; }
      | o = BooleanLiteral() { getQuery().addResultVar(s, 
NodeValue.makeNode(o)) ; getQuery().addJsonMapping(s, o) ; }
    ```
    
    More or less the same. But we have the Var (i.e. for cases like `"title" : 
?title`), and then I did not include the expressions (hence the lookahead 
removed).
    
    Does it make sense @afs ? If so, we can actually remove the `Number()` and 
this whole #if ARQ block. And I believe the code is doing more or less what you 
suggested?
    
    Thanks!
    Bruno


> 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)

Reply via email to