Browse Source

Format JSON for inspecting objects

This patch enables formatting for inspecting JSON objects. Example:

p({foo: "bar", deep: {foo: "bar"}})

becomes:

{
 "foo": "bar",
 "deep": {
  "foo": "bar"
 }
}
v0.7.4-release
Felix Geisendörfer 15 years ago
committed by Ryan Dahl
parent
commit
6e9e61b9df
  1. 2
      lib/sys.js

2
lib/sys.js

@ -28,7 +28,7 @@ exports.inspect = function (value) {
if (value === undefined) return; if (value === undefined) return;
try { try {
return JSON.stringify(value); return JSON.stringify(value, undefined, 1);
} catch (e) { } catch (e) {
// TODO make this recusrive and do a partial JSON output of object. // TODO make this recusrive and do a partial JSON output of object.
if (e.message.search("circular")) { if (e.message.search("circular")) {

Loading…
Cancel
Save