Add utility functions for working with JSON Pointer paths.

Review Request #9263 - Created Oct. 11, 2017 and updated

Christian Hammond
Djblets
release-0.10.x
a93e967...
djblets

This introduces two new JSON utility functions, json_get_pointer_info
and json_resolve_pointer, which are used to return information from a
JSON-compatible object based on a JSON Pointer path. These paths are a
standard way of specifying a location within an object, supporting
dictionary keys, array indices, and even an "end of array" marker (for
insertion purposes in other functions).

json_get_pointer_info attempts to resolve as much of the specified
path as possible, returning information on what was able to be resolved,
what remains, and what error should be shown if expecting a
fully-resolvable path. It's useful for cases where the path being used
may not necessarily have to represent an existing location in an object.

json_resolve_pointer takes a fully-resolvable Pointer path and returns
the value from the object that it matches. If the path cannot be
resolved, an exception is thrown. This is intended for use in the more
common cases of simply needing to access data from an object.

Unit tests passed.

  • 0
  • 0
  • 1
  • 0
  • 1
Description From Last Updated
Christian Hammond
David Trowbridge
Christian Hammond
Review request changed

Change Summary:

Consolidated some redundant logic around path splitting.

Commit:

-84b03f464ae511b06f3a2168790ee1860c15d1ee
+a93e96721938c926daa5d93b2662f6aef81c5dca

Diff:

Revision 3 (+810 -1)

Show changes

Checks run (2 succeeded)

JSHint passed.
flake8 passed.
Loading...