I have an object in typescript "obj". When I run:
console.log(obj);
It renders as the following in the terminal console:
[object Object]
It's only after i wrap it in a JSON.stringify(obj)
method that it renders the object as expected:
[{"allowed_values":["true"],"property":"pro1","required":"true"}]
What am I missing? Why is the object not being rendered as a JSON when I run "console.log()"?
Here is the scenario that captures the issue I am seeing:
violation = {"my_properties":[{"allowed_values":[{"Ref":"The bucket's logical resource name"}],"property":"BucketPolicy.Properties.Bucket","required":"true"}],"decision":"deny","message":"Some message.","policy_id":"FT_S3_0004","resource":"MyFirstBucketB8884501","type":"AWS::S3::Bucket","controls":["NIST-800-53-SA-8(2)"]}
console.log(violation)
This outputs:
{
my_properties: [
{
allowed_values: [Array],
property: 'BucketPolicy.Properties.Bucket',
required: 'true'
}
],
decision: 'deny',
message: 'Some message.',
policy_id: 'FT_S3_0004',
resource: 'MyFirstBucketB8884501',
type: 'AWS::S3::Bucket',
controls: [ 'NIST-800-53-SA-8(2)' ]
}
(notice that it prints [Array]
rather than the actual elements in the array).