Add utility functions for working with JSON Pointer paths.

Review Request #9263 — Created Oct. 11, 2017 and submitted

Christian Hammond

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
  2. djblets/util/ (Diff revision 2)

    This conditional is useless because if path is an empty string, path.split('/')[1:] will also be []

Christian Hammond
David Trowbridge
  1. Ship It!
Christian Hammond
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.10.x (9ef1fbe)