lib/activerdf_sparql-1.3.6/lib/activerdf_sparql/sparql.rb
# parse json query results into array
parse json query results into array
parse json query results into array
def parse_json(s)
    require 'json'
    parsed_object = JSON.parse(s)
    return [] if parsed_object.nil?
    results = []    
    vars = parsed_object['head']['vars']
    objects = parsed_object['results']['bindings']
    objects.each do |obj|
      result = []
      vars.each do |v|
        result << create_node( obj[v]['type'], obj[v]['value'])
      end
      results << result
    end
    results
  end
def parse_json ( s ) require 'json' parsed_object = JSON . parse ( s ) return [ ] if parsed_object . nil? results = [ ] vars = parsed_object [ 'head' ] [ 'vars' ] objects = parsed_object [ 'results' ] [ 'bindings' ] objects . each do | obj | result = [ ] vars . each do | v | result << create_node ( obj [ v ] [ 'type' ] , obj [ v ] [ 'value' ] ) end results << result end results end
parse json query results into array
parse json query results into array
# this will try to first load json with the native c extensions,  # and if this fails json_pure will be loaded
s