Add typing for serializable JSON values.
Review Request #13253 — Created Sept. 3, 2023 and submitted
Djblets 3.3 gained standard types for standard JSON values, which is
great when deserializing. However, when preparing data to be serialized
to JSON, we often need to work with datetimes, lazy strings, UUIDs, and
objects that can be serialized to JSON.To address this, we now have a new "serializable" set of JSON types,
which support all the values thatDjbletsJSONEncoder
(and parent
classes) support. This includes,date
,time
,datetime
,
timedelta
,UUID
,Promise
, andDecimal
values, along with
functions containing ato_json()
method.
DjbletsJSONEncoder
has been updated to include the typing support as
well, primarily for consistency and to help test the types. It also
drops explicit support forPromise
(lazy strings), since Django's
encoder supports that internally these days.Also of note, this does not contain typing used by the WebAPI resource
support. These types only work with this encoder and not the resource
encoder.
Unit tests pass in Djblets and Review Board.
Made use of these new types in some in-progress code.
Summary | ID |
---|---|
cbe033249c1dd08d37032d9688fb84dc26d76607 |