-3

wp_json_encode() prints the JSON string in one line. Can we make it pretty?

1 Answers1

0

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
  • 951
  • 1
  • 10
  • 18