Thursday 16 March 2017

Nodejs nested object isn't serialised?

When I require data.json in node Why node doesn't serialise info object in following json structure?

data.json

{
 "mailOptions": {
        "from": "from me",
        "service": "gmail",
        "auth": {
            "user": "username",
            "pass": "password",
           "info": {
               "name": "myname"
            }
        }
    }
}

The output result is:

> require('./data.json')
{ mailOptions:
   { from: 'from me',
     service: 'gmail',
     auth: { user: 'username', pass: 'password', info: [Object] } } }

There is an answer here which suggests to use util.inspect function but for some reason it isn't working for me.

So, Two questions:

  1. I am curious to know the reason behind this
  2. How I can get the complete object serialised?

Thanks



via Nexus23

No comments:

Post a Comment