snippetjavascriptCritical
How can I get the full object in Node.js's console.log(), rather than '[Object]'?
Viewed 0 times
objecthowfullconsolethanlogthenoderathercan
Problem
I have this object:
But when I try to show it using
How can I get the full object, including the content of property
const myObject = {
"a":"a",
"b":{
"c":"c",
"d":{
"e":"e",
"f":{
"g":"g",
"h":{
"i":"i"
}
}
}
}
};But when I try to show it using
console.log(myObject), I receive this output:{ a: 'a', b: { c: 'c', d: { e: 'e', f: [Object] } } }How can I get the full object, including the content of property
f?Solution
You need to use
Outputs
util.inspect():const util = require('util')
console.log(util.inspect(myObject, {showHidden: false, depth: null, colors: true}))
// alternative shortcut
console.log(util.inspect(myObject, false, null, true /* enable colors */))Outputs
{ a: 'a', b: { c: 'c', d: { e: 'e', f: { g: 'g', h: { i: 'i' } } } } }Code Snippets
const util = require('util')
console.log(util.inspect(myObject, {showHidden: false, depth: null, colors: true}))
// alternative shortcut
console.log(util.inspect(myObject, false, null, true /* enable colors */)){ a: 'a', b: { c: 'c', d: { e: 'e', f: { g: 'g', h: { i: 'i' } } } } }Context
Stack Overflow Q#10729276, score: 2267
Revisions (0)
No revisions yet.