Magento Json用新线编码(漂亮/回车)

时间:2013-03-19 09:27:54

标签: json magento printing encode

我将数组编码为json并获取

{"payment_providers":[{"name":"ccsave","revenue":[{"date":"2013-03-18","sales":"51.00","items":"2","median_item_price":"20.50"}]},{"name":"checkmo","revenue":[{"date":"2013-03-18","sales":"79.00","items":"5","median_item_price":"8.00"}]},...

但我需要:

{
    "payment_providers":[
       {"name":"ccsave",
        "revenue":[
            {"date":"2013-03-18","sales":"51.00","items":"2","median_item_price":"20.50"}
         ]
        },
        {"name":"checkmo","revenue":[
           {"date":"2013-03-18","sales":"79.00","items":"5","median_item_price":"8.00"}
         ]
        }, ...

我怎样才能让Json看起来漂亮?

1 个答案:

答案 0 :(得分:1)

有一个PHP函数json-encode,请在此处查看文档:{​​{3}}

并在此处查看类似问题:http://php.net/manual/en/function.json-encode.php