Return JSON Data with AJAX call in Magento 2

Today, we will see how to return json data from controller while doing an ajax call.
Situation may come that you are doing some customization and need to deal will json data from controller then here is the way how we can go for it.