Sunday, April 7, 2019

Console.table to print tabular view of JSON

Suppose if we have a DOM element named Employee which has JSON (JavaScript Object Notation) content  within. And we would like to view a tabular format of it over console (from developer tools of chrome). We can achieve it using "console.table". Refer to below screenshot.

Note:

  • This developer tip is helpful during debugging web application to see the JSON content in a tabular format. 
  • And for those who are new to browser console, feel free to start by executing this command.
  • This can be applied any web application during debugging. So we can use this for Pega applications also during debugging javascript code (usually during custom code).
  • console.table is one of the useful commands. Likewise we got some basic commands like (console.log, console.error, console.warn, .... ) which can be explored from web.
Example:
 


Assume there is a javascript variable "emp" which holds the list of employees. And we would like to understand the model by looking at a tabular column, then console.table command would help.
To naviagate to console : Open Developer Tools > Console from Chrome. Or directly use Ctrl+Shift+J from chrome browser.


No comments:

Post a Comment


HowToPega : All rights reserved and the contents are copyrighted to Pavan Kumar Naidu