avatar
convert object to json string Javascript

First and foremost, let us start with an example before moving on to a real-life scenario.

const obj = { name: 'John', age: 30 };
console.log(JSON.stringify(obj));

Here's an example:

{"name":"John","age":30}

Here is a practical example of using console.log in a Lambda function.

await client.query("select * from \"tblsample\" where userid =  " + `${userid}`);
console.log(JSON.stringify(res));
You need to login to do this manipulation!