![]() This function has an argument that used to pass the JSON data. A user-defined function, pretty_print() is used in the code to format the JSON data. A large JSON data is used in this example that is stored in the variable, $data. Create a PHP file named exp4.php with the following code. How you can apply CSS in JSON data using PHP is mainly shown in this example. But if you want to print JSON data with the custom format then it is better to use the user-defined function of PHP. Example-4: Colorful JSON printing using the custom functionįormatted JSON data are printed by using JSON_PRETTY_PRINT option of PHP in the previous examples. The following output will appear after executing the file from the browser. ‘Jon Duckett’ = > ‘HTML & CSS: Design and Build Web Sites’, ‘Rob Foster’ = > So, JSON data will be printed in a single line in JSON format. No formatting is applied for JSON data in the code. Here, an associative array is declared to generate JSON data. Create a file named exp1.php with the following code to read a simple JSON data and print the output. Json_encode() function of PHP is used to parse any JSON data. How you can apply JSON pretty printing using PHP is shown in this tutorial by using various examples. There are many ways to apply pretty printing in JSON data. JSON data can be represented in a more readable form for humans by using pretty printing. Pretty print is used to format the JSON data. So, the formatted JSON data is very important to understand the structure of the data for the reader. ![]() But this type of output is not so easier to understand. JSON data prints in a single line when no formatting is applied. It is a human-readable file format that is easily understood by anyone if it prints with proper formatting. It is derived from JavaScript and supported by many standard programming languages. Also, we have covered these topics.JSON is a popular data storage format to exchange data between server and browser. In this tutorial, we have learned about Python pretty print JSON. You may also like to read the following articles.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |