How can I beautify JSON programmatically?
You might say this is duplicate of this question, but original question WASN'T answered there. Important part of question is: programmatically
?
Is there any php function? Native or homemade?
Looks like this might work:
http://recursive-design.com/blog/2008/03/11/format-json-with-php/
genesis's result:
[[["er",null,null,null,null,500],["e",2,null,null,57]],'45932b7d6d6dc08e']
to
[
[
[
"er",
null,
null,
null,
null,
500
],
[
"e",
2,
null,
null,
57
]
],
'45932b7d6d6dc08e'
]
json_encode()有一个标志JSON_PRETTY_PRINT
echo json_encode($data, JSON_PRETTY_PRINT);
had the same question right now. But as you also i'm having php < 5.4. Zend Framework has Zend_Json::prettyPrint(). Works very well.
链接地址: http://www.djcxy.com/p/48198.html下一篇: 如何以编程方式美化JSON?