Skip to content

Commit becde37

Browse files
committed
Stricter JSON validation
1 parent 2ba4482 commit becde37

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Gren/Kernel/Json.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function _Json_runHelp(decoder, value) {
231231

232232
var keyValuePairs = [];
233233
for (var key in value) {
234-
if (value.hasOwnProperty(key)) {
234+
if (Object.hasOwn(value, key)) {
235235
var result = _Json_runHelp(decoder.__decoder, value[key]);
236236
if (!__Result_isOk(result)) {
237237
return __Result_Err(
@@ -414,7 +414,10 @@ function _Json_emptyObject() {
414414
}
415415

416416
var _Json_addField = F3(function (key, value, object) {
417-
object[key] = _Json_unwrap(value);
417+
var unwrapped = _Json_unwrap(value);
418+
if (!(key === "toJSON" && typeof unwrapped === "function")) {
419+
object[key] = unwrapped;
420+
}
418421
return object;
419422
});
420423

0 commit comments

Comments
 (0)