cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Cypher query convert relationships JSON to text

CD007
Node Link

Hi

I have the following Cypher query

query = """MATCH (n {name: '%s'})-[r]->(b) RETURN *""" % (entity_type)
 
and its returning the error 
 
TypeError: Object of type Node is not JSON serializable.
 
I was able to successfully convert another query to text which was a list by doing the following with json dumps library - 
 
query = """MATCH (n {name: ('%s')}) RETURN n.description""" % (entity_type)
result = json.dumps(conn.query(query))
 
to successfully convert to a string however this isn't working for the returned relationships query.
 
Can anyone advise thanks?
 
Also is it possible to retrieve the query so it appears visually with the nodes and relationships? I've looked on the Neo4j page at Export to JSON - APOC Documentation (neo4j.com) but I can't work out what I should do with the returned result to make it appear as a visual graph in my web page.
 
Thanks
 
Chris
 

 

1 REPLY 1

Hi @CD007 

You are using a python driver to query the database as I can see. Why you do not try to return a list of the results by adding tx.run(query).data() as mentioned in the driver documentation here: https://neo4j.com/docs/api/python-driver/current/api.html#neo4j.Result.data