How Can I Use Py2neo To Store A Dictionary As One Property Value To Single Property Key Of A Node In Neo4j?
Solution 1:
Neo4j only supports certain kinds of properties (docs):
...there are restrictions as to what types of values can be used as property values. Allowed value types are as follows:
Numbers: Both integer values, with capacity as Java’s
Long
type, and floating points, with capacity as Java’sDouble
.Booleans.
Strings.
Arrays of the basic types above.
You therefore cannot set a dictionary as a property. You could try using json.dumps
to convert the dictionary to a JSON string and storing the string. However, this will mean that you cannot easily use the content of the object when writing queries, and will need to json.loads
the data back when you retrieve the node.
Alternatively, you could make the object a separate node with the properties year1
, year2
, etc., and link it to the first node with a relationship.
Post a Comment for "How Can I Use Py2neo To Store A Dictionary As One Property Value To Single Property Key Of A Node In Neo4j?"