Pretty-Printing JSON with PHP

后端 未结 24 1835
一向
一向 2020-11-22 02:03

I\'m building a PHP script that feeds JSON data to another script. My script builds data into a large associative array, and then outputs the data using json_encode

24条回答
  •  一向
    一向 (楼主)
    2020-11-22 02:56

    If you have existing JSON ($ugly_json)

    echo nl2br(str_replace(' ', ' ', (json_encode(json_decode($ugly_json), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES))));
    

提交回复
热议问题