diff --git a/NiL.JS/BaseLibrary/JSON.cs b/NiL.JS/BaseLibrary/JSON.cs index a1cc5eeb6..04033638f 100644 --- a/NiL.JS/BaseLibrary/JSON.cs +++ b/NiL.JS/BaseLibrary/JSON.cs @@ -33,7 +33,7 @@ private class StackFrame [ArgumentsCount(2)] public static JSValue parse(Arguments args) { - var length = Tools.JSObjectToInt32(args._iValue); + var length = args._iValue; var code = args[0].ToString(); Function reviewer = length > 1 ? args[1]._oValue as Function : null; return parse(code, reviewer); @@ -474,7 +474,7 @@ private static string stringifyImpl(string key, JSValue obj, Function replacer, processed.Add(obj); if (obj.Value == null) - return null; + return "null"; if (obj._valueType == JSValueType.Function) return null; diff --git a/NiL.JS/Core/JSValue.cs b/NiL.JS/Core/JSValue.cs index 848b9c859..8efc33108 100644 --- a/NiL.JS/Core/JSValue.cs +++ b/NiL.JS/Core/JSValue.cs @@ -862,6 +862,9 @@ private object debugValue() return Value; } + if (Value is null) + return "null"; + return (_oValue as JSValue ?? this)._valueType; } diff --git a/Tests/Fuzz/Bug_282.js b/Tests/Fuzz/Bug_282.js new file mode 100644 index 000000000..9615860ca --- /dev/null +++ b/Tests/Fuzz/Bug_282.js @@ -0,0 +1,2 @@ +if (JSON.stringify({ a: null }) !== '{"a":null}') + console.error("JSON.stringify ignores null"); \ No newline at end of file