Pretty-Printing JSON with PHP

后端 未结 24 2224
一向
一向 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 03:07

    Gluing several answers together fit my need for existing json:

    Code:
    echo "
    "; 
    echo json_encode(json_decode($json_response), JSON_PRETTY_PRINT); 
    echo "
    "; Output: { "data": { "token_type": "bearer", "expires_in": 3628799, "scopes": "full_access", "created_at": 1540504324 }, "errors": [], "pagination": {}, "token_type": "bearer", "expires_in": 3628799, "scopes": "full_access", "created_at": 1540504324 }

提交回复
热议问题