Skip to content

Commit

Permalink
Ensured that SPARQL 1.1 JSON typed literals are parsed correctly.
Browse files Browse the repository at this point in the history
The parsing code now supports both SPARQL 1.0 and 1.1 JSON results:

    {"type": "literal", "value": "S", "datatype": "D"}        # SPARQL 1.1 JSON
    {"type": "typed-literal", "value": "S", "datatype": "D"}  # SPARQL 1.0 JSON

See: http://www.w3.org/TR/sparql11-results-json/#select-encode-terms
See: http://www.w3.org/TR/rdf-sparql-json-res/#variable-binding-results
  • Loading branch information
artob committed Aug 11, 2014
1 parent 37268c4 commit 6e86709
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/sparql/client.rb
Expand Up @@ -380,6 +380,7 @@ def self.parse_json_bindings(json, nodes = {})
##
# @param [Hash{String => String}] value
# @return [RDF::Value]
# @see http://www.w3.org/TR/sparql11-results-json/#select-encode-terms
# @see http://www.w3.org/TR/rdf-sparql-json-res/#variable-binding-results
def self.parse_json_value(value, nodes = {})
case value['type'].to_sym
Expand All @@ -388,7 +389,7 @@ def self.parse_json_value(value, nodes = {})
when :uri
RDF::URI.new(value['value'])
when :literal
RDF::Literal.new(value['value'], :language => value['xml:lang'])
RDF::Literal.new(value['value'], :datatype => value['datatype'], :language => value['xml:lang'])
when :'typed-literal'
RDF::Literal.new(value['value'], :datatype => value['datatype'])
else nil
Expand Down

0 comments on commit 6e86709

Please sign in to comment.