How to pretty JSON fromat using JavaScript/jQuery?

Pretty JSON example

Pretty JSON example

So many time we required ti print the JSON in pretty format because it is easy to read and understood. As we know JSON (JavaScript object notation)  is a lightweight data-interchange format. It is easy for humans to read and write.
In this article you will learn how to print JSON in pretty format at browser.



Here is the CSS code create a new css file named as stylesheet.css.
stylesheet.css

I have used CSS for highlighting the key, value and strings.
Here is the JavaScript and HTML code to print the JSON in pretty format.



index.html

Here in JavaScript I have cerated a function to make the JSON in pretty format. Here we have a products JSON and we are printing products JSON in pretty format. ...  Read More

Share This:


How do I get HTTP Request body content in Laravel | How to return JSON Request body in Response in Laravel | How to add new parameter in HTTP request body in Laravel

So many time we need to return in REST APIs the request body. For example if you send a POST request with some parameters and you wanted you API access token along with the request body parameters which you sent.

Like below example:

Here is the Request body:

And now you wanted to get register and access token in response along with above request body like below:

How can we do this in Laravel????

Here is the answer of this question. You can get the HTTP request body in Laravel by following code:

Now if you wanted to send the request body with along with access token in JSON response in Laravel, You can do it like following example:

So finally function to return the JSON response after registration of the user looks like:

  ...  Read More

Share This: