wp_json_encode() prints the JSON string in one line. Can we make it pretty?
Asked
Active
Viewed 695 times
1 Answers
1
You can make use of wp_json_encode() options parameter.
Setting options to JSON_PRETTY_PRINT
as an argument will make the function use whitespace in returned data to format it:
wp_json_encode($data, JSON_PRETTY_PRINT);

bitski
- 1,168
- 1
- 13
- 20