This commit is contained in:
Thomas Weißschuh 2024-05-03 11:01:29 +01:00 committed by GitHub
commit c0f5df0ef2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 1 deletions

View File

@ -7,6 +7,17 @@
import DishType from "./DishType.mjs";
import Utils from "../Utils.mjs";
/**
* Serialize Maps which are not natively compatible with JSON as an array of
* key-value-paris.
*/
function jsonStringifyReplacer(k, v) {
if (v instanceof Map) {
return [...v];
}
return v;
}
/**
* Translation methods for JSON dishes
*/
@ -17,7 +28,7 @@ class DishJSON extends DishType {
*/
static toArrayBuffer() {
DishJSON.checkForValue(this.value);
this.value = this.value !== undefined ? Utils.strToArrayBuffer(JSON.stringify(this.value, null, 4)) : new ArrayBuffer;
this.value = this.value !== undefined ? Utils.strToArrayBuffer(JSON.stringify(this.value, jsonStringifyReplacer, 4)) : new ArrayBuffer;
}
/**