Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions jsonpointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,15 @@ def set(self, doc, value, inplace=True):

(parent, part) = self.to_last(doc)

if isinstance(parent, Sequence) and part == '-':
if isinstance(parent, str):
raise JsonPointerException("Cannot set value in a string")
elif isinstance(parent, Sequence) and part == '-':
parent.append(value)
else:
parent[part] = value
try:
parent[part] = value
except (TypeError, IndexError) as e:
raise JsonPointerException("Invalid assignment target: %s" % (e,))
Comment on lines +217 to +220

return doc

Expand Down
Loading