Add utility functions for working with JSON Pointer paths.
Review Request #9263 — Created Oct. 11, 2017 and submitted — Latest diff uploaded
This introduces two new JSON utility functions,
json_get_pointer_info
andjson_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.