Question

Using python/py2neo, I run a cypher query containing

return ..., ...,  collect([node1.uuid, node1.timestamp, id(node1), node2.uuid])

Both in web console and py2neo I get back a result looking like this:

[ ..., ..., [u'List(1234abcd-1234-1234-1234-1234abcd1234, 1.374650647E9, 13312, 4321abcd-4321-4321-4321-4321abcd4321)', u'List(..., ..., ...)']]

(just with "" instead of u'' in web console)

It doesn't look like JSON. There's a u'List()', unquoted strings and scientific notation.

How is it possible to parse returned collections of lists?

Was it helpful?

Solution

You could do it with regex:

import re
s = u'List(1234abcd-1234-1234-1234-1234abcd1234, 1.374650647E9, 13312, 4321abcd-4321-4321-4321-4321abcd4321)'
re.findall(r'List\(([a-z0-9-]+), ([0-9.E]+), (\d+), ([a-z0-9-]+)\)', s)

this would return:

[(u'1234abcd-1234-1234-1234-1234abcd1234',
  u'1.374650647E9',
  u'13312',
  u'4321abcd-4321-4321-4321-4321abcd4321')]

OTHER TIPS

If you look at the actual REST calls (switch to the HTTP console view or use CURL), you can do in the HTTP Webadmin Console something like

POST /db/data/cypher {"query":"start n=node(1,2) return collect(n);"}

And will get correct serialized full node red=representations in a [] back.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top