def jsondict2graph(json_dict):
    g = Graph()
    [g.bind(*x) for x in ns_store.items()]
    for triple in json_dict['results']['bindings']:
        ts = triple['s'].get('type',None)
        vs = triple['s']['value']
        if ts == 'uri':
            s = URIRef(vs)
        elif ts == 'literal':
            s = Literal(vs)
        elif ts == 'bnode':
            s = BNode(vs)
        #logging.debug(s)
        
        p = URIRef(triple['p']['value'])
        #logging.debug(p)
        
        to = triple['o'].get('type',None)
        vo = triple['o']['value']
        dto = triple['o'].get('datatype',None)
        if to == 'uri':
            o = URIRef(triple['o']['value'])
        elif to == 'literal':
            o = Literal(triple['o']['value'])
            if dto:
                o.datatype = URIRef(dto)
        elif ts == 'bnode':
            o = BNode(vo)
        #logging.debug(o)
        g.add((s,p,o))
    logging.debug(g.serialize(format='turtle'))
    return g