Cypher query convert relationships JSON to text

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

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