1

should be a simple one but I can't find an answer..

I am console logging some parsed Json but it only shows one level and does not show the deeper objects in the log..

{ jsonrpc: '2.0',
  result: 
   [ { marketId: '1.118750017',
       marketName: 'Match Odds',
       marketStartTime: '2015-05-12T15:30:00.000Z',
       totalMatched: 52.32,
       runners: [Object],
       eventType: [Object],
       competition: [Object],
       event: [Object] } ],
  id: 1 }

How do I log and expand on the items showing as objects above. I know they exist but can't print them out to the screen.

code is simply;

var response = JSON.parse(str);
console.log(response);

If I console log str I get all the data in a not very readable format.

Thanks

Bwizard
  • 955
  • 2
  • 15
  • 36

2 Answers2

2

Try using the util.inspect method with these options:

var util = require('util');

console.log(util.inspect(response, {showHidden: false, depth: null}));
Steve Hynding
  • 1,799
  • 1
  • 12
  • 22
0

Try the following: JSON.stringify(response);

Pavel Kolev
  • 111
  • 8