We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 9641b05 + aeafa7d commit 226e639Copy full SHA for 226e639
index.js
@@ -15,7 +15,7 @@ function objToJson (obj) {
15
return Object.keys(obj).reduce(function (memo, key) {
16
if (typeof obj[key] === 'function') {
17
memo[key] = obj[key].toString()
18
- } else if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
+ } else if (typeof obj[key] === 'object' && !Array.isArray(obj[key]) && obj[key] !== null) {
19
memo[key] = objToJson(obj[key])
20
} else {
21
memo[key] = obj[key]
test/expected/null-example.js.json
@@ -0,0 +1,4 @@
1
+{
2
+ "_id": "null-example",
3
+ "null-field": null
4
+}
test/fixtures/null-example.js
+module.exports = {
+ _id: 'null-example',
+ 'null-field': null
0 commit comments