How build custom json api controller for category wise post in wordpress?

Here is the custom json api controller code for category wise post in wordpress:  

How to add CSS class in WordPress NAV anchor tag?

I am using Bootstrap 4 and my menu structure like this:

Let’s start adding menu dynamically on wordpress custom theme.

I am calling WP Nav in header.php file like this:

Now, add this function on function.php file.

How to vertically center a div for all browsers?

Below is the best all-around solution I have found. Tested and working for all browser.