3 ms·
I’m going to send you some json to update your object – an HTTP PATCH request. There are three possible updates I might want to make to the subscription field:
by dan-robertson 2y ago
I’m going to send you some json to update your object – an HTTP PATCH request. There are three possible updates I might want to make to the subscription field:
- change it to a new value
- set it to None
- leave it as-is
In the json the first two options are specified by sending an object with a "subscription" field, either set to a string or to null. The third case is expressed by omitting the field.
The OP asks how all three cases could be represented in python, and points out that one could not use subscription=None to represent both case 2 and 3 above.
- RHSeeger 2y agoIf you need to be able to represent what looks like a tree of data set - no value - new value do_no_set (sorry about the horrible tree) then it seems like you should represent the data like that. Pass in action (set/ignore) and value (value for set, no value for ignore). Or even (set/unset/ignore), which allows you to have some sanity checking that, if the action is set, an actual value is provided (and vice versa for unset).