Node.js dirty how do i get data from [Object object]?

How to i get the data from from [Object object]?

Here is an example of what i'm trying to do.

// Get data with dirty
var data = db.get('/htmltest')

// My test.db file
{"key":"foo","val":"barwhat?"}
{"key":"/htmltest","val":{"title":"Html Test","content":"<span>This is HTML</span>"}}


// the console.log gives me [Object Object]
// How do I get it to show the content of title (Html Test)
console.log(data);

According to the documentation, the get method returns the value for a given key. In that case you should be able to access the title property like so:

// Get data with dirty
var data = db.get('/htmltest')

// My test.db file
{"key":"foo","val":"barwhat?"}
{"key":"/htmltest","val":{"title":"Html Test","content":"<span>This is HTML</span>"}}


// the console.log gives me [Object Object]
// How do I get it to show the content of title (Html Test)
console.log(data.title);

Another thing that you can do to help view your data for debugging is to use the util inspect function.

var util = require('util');
var data = db.get('/htmltest');

console.log(util.inspect(data));

Again, this is only useful for debugging and inspecting the contents of objects.

If you certify that your data variable is a JSON object, you can also parse easily it and show all content in one row using JSON.stringify(data);