Repository navigation
Conversation
|
@stefankoegl Could you please review this PR? |
|
Hi! Thanks for your contribution! As requests is not part of the standard library, I am hesitant of adding a dependency for a single call. Can you change that to unquote from the stdlib? Also I am not sure if it makes sense to use the same call to detect and process both kinds of json pointer representations. Can you please elaborate a bit on your use case? |
|
I can use the stdlib version. I think there's some quirks between python2 and python3 so I'll be sure to keep that in mind. The use case is that I have json schemas which have internal refs, e.g. I am manipulating these schemas and have a need to fetch the object pointed by the refs. rfc6901 says that it supports this type of pointer so I think it makes sense to process both kinds in the init. I am not sure I understand what you mean by using a different call. |
|
I don't think this is correct in its current form as it causes the JsonPointer class to accept syntax that isn't JSON Pointer. RFC 6901 section 6 talks about how to layer the URI syntax with JSON Pointer syntax:
This isn't the same thing as saying that "#" is part of the JSON Pointer syntax. Rather, you should use a URL parser such as hyperlink to parse the URL, then use the pointer from the fragment normally. For example: from hyperlink import URL
from jsonpointer import JsonPointer
url = URL.from_text(u'#/definitions/bar')
pointer = JsonPointer(url.fragment)Note that JSON Schema's |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Fragment decoding occurs in the wrong order, and the new undeclared requests dependency can break imports.
Review effort: Balanced
Findings: 1
Open (2)
What changed in this PR
Adds URI-fragment JSON Pointer support to the core parser.
Changes:
- Accepts pointers beginning with
#. - Adds URI-fragment specification tests.
| File | Description |
|---|---|
jsonpointer.py |
Adds fragment decoding and prefix handling. |
tests.py |
Covers standard URI-fragment examples. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| parts = [unescape(part) for part in parts] | ||
| if first_part == '#': | ||
| parts = [unquote(part) for part in parts] |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |


Json pointers which start with '#' are currently not supported. This adds support for them.
Note: I am adding a dependency on
requests, but I am not sure if that comes with standard python now.