Skip to content

Commit

Permalink
Fix json serialization error in Python Driver (apache#1228)
Browse files Browse the repository at this point in the history
* * Added test to catch the error in toJson()
* removed the trailing comma in _nodeToJson() node.properties part
* removed the trailing comma in _nodeToString() node.properties part

* * Added missing ", ".join() _nodeToString() in node.properties part

---------

Co-authored-by: Olivier <[email protected]>

Resolved -

Conflicts:
	drivers/python/test_age_py.py
  • Loading branch information
omaurel-socha authored and jrgemignani committed Feb 13, 2024
1 parent 614b0ce commit deb651d
Show file tree
Hide file tree
Showing 2 changed files with 429 additions and 379 deletions.
24 changes: 13 additions & 11 deletions drivers/python/age/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,12 @@ def _nodeToString(node, buf, extraFormatter=None):

if node.properties != None:
buf.write(", properties:{")
for k,v in node.properties.items():
buf.write(k)
buf.write(": ")
buf.write(str(v))
buf.write(", ")
prop_list = []
for k, v in node.properties.items():
prop_list.append(f"{k}: {str(v)}")

# Join properties with comma and write to buffer
buf.write(", ".join(prop_list))
buf.write("}")

if extraFormatter != None:
Expand Down Expand Up @@ -281,12 +282,13 @@ def _nodeToJson(node, buf, extraFormatter=None):

if node.properties != None:
buf.write(", \"properties\":{")
for k,v in node.properties.items():
buf.write("\"")
buf.write(k)
buf.write("\": \"")
buf.write(str(v))
buf.write("\", ")

prop_list = []
for k, v in node.properties.items():
prop_list.append(f"\"{k}\": \"{str(v)}\"")

# Join properties with comma and write to buffer
buf.write(", ".join(prop_list))
buf.write("}")
buf.write("}")

Loading

0 comments on commit deb651d

Please sign in to comment.