The underlying return of such JSON string, in the front-end or PHP section how to change N and T to the corresponding carriage return and tab symbol?

Source: Internet
Author: User
Tags epoll
{"msg":"{\n \"iaback\" : {\n \"code\" : -3522,\n \"msg\" : \"\"\n },\n \"iawork\" : {\n \"code\" : 0,\n \"msg\" : \"---------------LibRxTx Info:--------------\\nCurrent peer:\\t4\\nWork Thread 0 235\\nWork Thread 1 255\\nWork Thread 2 247\\nWork Thread 3 244\\nEpLoop\\t\\t2513\\nEpRead\\t\\t1876\\nEpMoreRead\\t0\\nEpWrite\\t\\t895\\nSndLoop\\t\\t2183\\nPeerSnd\\t\\t1805\\nSndSw\\t\\t0\\nBufSnd\\t\\t908\\nAccept\\t\\t1778\\nPeerRcv\\t\\t1085\\nBufRcv\\t\\t1974\\nAddJob\\t\\t988\\nGetJob\\t\\t986\\nGetMore\\t\\t985\\nPktSnd\\t\\t888\\nPktRcv\\t\\t889\\nSndWait\\t\\t0\\nSndWaitAck\\t0\\n-------> Epoll 0\\nIdx ID RID State pktSnd ackRcv pktRcv pktExe ackSnd bw(Bps) Zip Retry\\tName\\n0 1 0 Lsn 0 0 0 0 0 -1 100 0\/-1\\t 127.0.0.1:26826 <--> :\\n1 2 0 Try 0 0 0 0 0 -1 100 96\/-1\\t :44115 <--> 192.168.17.9:26828\\n2 891 0 OK 0 0 1 0 0 -1 100 0\/-1\\tIPC 127.0.0.1:26826 <--> 127.0.0.1:57872\\n\"\n }\n}\n","result":0} 

I want to display a formatted, readable JSON string on the front

Reply content:

{"msg":"{\n \"iaback\" : {\n \"code\" : -3522,\n \"msg\" : \"\"\n },\n \"iawork\" : {\n \"code\" : 0,\n \"msg\" : \"---------------LibRxTx Info:--------------\\nCurrent peer:\\t4\\nWork Thread 0 235\\nWork Thread 1 255\\nWork Thread 2 247\\nWork Thread 3 244\\nEpLoop\\t\\t2513\\nEpRead\\t\\t1876\\nEpMoreRead\\t0\\nEpWrite\\t\\t895\\nSndLoop\\t\\t2183\\nPeerSnd\\t\\t1805\\nSndSw\\t\\t0\\nBufSnd\\t\\t908\\nAccept\\t\\t1778\\nPeerRcv\\t\\t1085\\nBufRcv\\t\\t1974\\nAddJob\\t\\t988\\nGetJob\\t\\t986\\nGetMore\\t\\t985\\nPktSnd\\t\\t888\\nPktRcv\\t\\t889\\nSndWait\\t\\t0\\nSndWaitAck\\t0\\n-------> Epoll 0\\nIdx ID RID State pktSnd ackRcv pktRcv pktExe ackSnd bw(Bps) Zip Retry\\tName\\n0 1 0 Lsn 0 0 0 0 0 -1 100 0\/-1\\t 127.0.0.1:26826 <--> :\\n1 2 0 Try 0 0 0 0 0 -1 100 96\/-1\\t :44115 <--> 192.168.17.9:26828\\n2 891 0 OK 0 0 1 0 0 -1 100 0\/-1\\tIPC 127.0.0.1:26826 <--> 127.0.0.1:57872\\n\"\n }\n}\n","result":0} 

I want to display a formatted, readable JSON string on the front

Do you want to display the formatted JSON on the browser?
Var_export (Json_decode ($json _string)); try this. You can format the structure of the saved object.
But if you're on the browser, it doesn't fit, and he prints the object information.
Show only JSON formatted characters, there are two ways to see your PHP version 5.4 before you write your own processing functions, Google a lot of.
After 5.4 versions can be directly like this:
Echo Json_encode ($arr, json_unescaped_unicode| Json_pretty_print);
The printed result is the finished format.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.