Add utility functions for working with JSON Pointer paths.

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

Information

Djblets
release-0.10.x
a93e967...

Reviewers

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.

Description From Last Updated

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

daviddavid
chipx86
david
  1. 
      
  2. djblets/util/json_utils.py (Diff revision 2)
     
     
     
     
     

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

  3. 
      
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.10.x (9ef1fbe)
Loading...