Commit 01f0c86a authored by Aurélien Vermylen's avatar Aurélien Vermylen

Fix util.stringify for null objects.

jIO.util.stringify({y: null}) used to error. Now it behaves similarly
to JSON.stringify, returning '{"y":null}'.
parent 81cb08dd
...@@ -132,6 +132,9 @@ ...@@ -132,6 +132,9 @@
if (obj === undefined) { if (obj === undefined) {
return undefined; return undefined;
} }
if (obj === null) {
return 'null';
}
if (obj.constructor === Object) { if (obj.constructor === Object) {
key_list = Object.keys(obj).sort(); key_list = Object.keys(obj).sort();
result_list = []; result_list = [];
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
equal(str(Object.create(null, { x: { value: 'x', enumerable: false }, equal(str(Object.create(null, { x: { value: 'x', enumerable: false },
y: { value: 'y', enumerable: true } })), y: { value: 'y', enumerable: true } })),
'{"y":"y"}'); '{"y":"y"}');
equal(str({y: "y", testnull: null}),
'{"testnull":null,"y":"y"}');
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment