• 
      

    Add two new methods for storing JSON extra_data in the API.

    Review Request #9271 — Created Oct. 16, 2017 and submitted — Latest diff uploaded

    Information

    Review Board
    release-3.0.x
    8171038...

    Reviewers

    Our extra_data support in the API has previously been limited to
    storing primitive values (strings, booleans, integers) associated with
    top-level keys. It didn't allow for any complex JSON data.

    This change introduces two new methods for storing and managing more
    complex JSON data. Clients can now set the extra_data:json field in
    POST or PUT to a serialized JSON Merge Patch, which is a JSON document
    that will be merged into the root of extra_data. Keys mapped to
    dictionaries in the document will merge the dictionary from the JSON
    Merge Patch. Arrays will replace arrays. Any key set to None will
    remove that key from the dictionary. This is a pretty good,
    straight-forward way of working with JSON data.

    For more advanced usage, clients can set extra_data:json-patch to a
    JSON Patch document, which is a list of operations to perform on
    extra_data. This allows for setting entire JSON structures on
    dictionary keys, at the end of an array, or even at specific array
    indices. Operations can remove parts of the JSON document, copy/move
    data. They can also sanity-check the presence of existing data, aborting
    the entire patch if not present.

    Both forms of patches prevent replacing the entire root resource itself
    (though every key can be specifically deleted), so that clients don't
    accidentally remove all state. They also obey any access restrictions
    imposed by extensions, preventing reading from private parts of a tree
    and writing to private/read-only parts of a tree. Keys with double
    underscores (__keyname) are also still supported, and can occur at any
    level of the tree.

    Documentation on all of this will be added in a future change.

    Unit tests pass.

    Manually tested that both forms of patching work.