Search code examples
javascriptloggingstringify

Object properties "blank" unless called specifically


I have an object, let's say current_group. I am trying to print this object and it's contents to the screen so I can analyze it's properties (this is being pulled from an external system so I don't have docs on what to expect).

Anyways, I tried the following calls, and they resulted with just blank properties ex. { id: '', status: '' }

log.info(current_group);
log.info(JSON.stringify(current_group));

So, then I thought on a whim, I would try log.info(current_group.id) and it worked, it printed to the screen no issue and I didn't have to stringify it either.

Any idea what is happening here and how I can get the entire object contents to print in one call?


Solution

  • Try to iterate through object:

    var output = '';
    for (let property in current_group) {
      output += property + ': ' + current_group[property]+'; ';
    }
    log.info(output);