简体   繁体   中英

How to pretty print JSON with wp_json_encode()?

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

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM