The encoder and decoder are expected to be objects following the JSONEncoder and JSONDecoder interfaces, respectively. Thus, the orjson dumps and loads functions cannot be used directly.
Define JSONEncoder and JSONDecoder subclasses which wrap orjson, and use these as the encoder and decoder for OrjsonField.
This field was only used by the /api/notification_settings/ settings endpoint, so that endpoint should now be able to work. Previously, it always reported a JSON validation error for the condition field. To test it, the following code can be used
(async () => {
let response = await fetch(
"/api/notification_settings/",
{
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-CSRFToken': getCookie('csrftoken'),
},
mode: 'same-origin',
body: JSON.stringify({
condition: {"var": 1},
destination: ["EM", "WE"],
test: 1, // This test needs to be created beforehand
message: "hello"
}),
}
);
let content = await response.json();
console.log(content);
})();
The encoder and decoder are expected to be objects following the
JSONEncoder
andJSONDecoder
interfaces, respectively. Thus, the orjsondumps
andloads
functions cannot be used directly.Define
JSONEncoder
andJSONDecoder
subclasses which wrap orjson, and use these as the encoder and decoder forOrjsonField
.This field was only used by the
/api/notification_settings/
settings endpoint, so that endpoint should now be able to work. Previously, it always reported a JSON validation error for thecondition
field. To test it, the following code can be used