Skip to content
Open
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
7 changes: 6 additions & 1 deletion jsonpointer.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,13 @@ def set(self, doc, value, inplace=True):

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

return doc

Expand Down