summaryrefslogtreecommitdiff
path: root/jsonschema/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'jsonschema/exceptions.py')
-rw-r--r--jsonschema/exceptions.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/jsonschema/exceptions.py b/jsonschema/exceptions.py
index 691dcff..deae872 100644
--- a/jsonschema/exceptions.py
+++ b/jsonschema/exceptions.py
@@ -118,6 +118,16 @@ class _Error(Exception):
path.extendleft(reversed(parent.absolute_schema_path))
return path
+ @property
+ def json_path(self):
+ path = '$'
+ for elem in self.absolute_path:
+ if isinstance(elem, int):
+ path += '[' + str(elem) + ']'
+ else:
+ path += '.' + elem
+ return path
+
def _set(self, **kwargs):
for k, v in iteritems(kwargs):
if getattr(self, k) is _unset: