A dictionary of js, what to do if you break the line?

for example, the backend sends me an object

a = {"a":1,"b":2,"c":3}

display an in the td of a table, so it"s a row directly. It"s ugly. I want to be

.
{
    "a":1,
    "b":2,
    "c":3
}
Can

be implemented?


When

is sent to you, it is usually JSON, right?
the Ajax method you use should automatically convert it to an object, and you use JSON.stringify to convert it into a string, which can be formatted by adding a third parameter. (the second parameter is used to filter the attributes that need to be converted to a string. Just set null by default. The third parameter, if it is a number, is the space before each line of attributes wrap, and if it is a string, it will be added to the front of each line of attributes)
in addition, it should be noted that the white-space attribute of the container where the string is located is generally the default value normal , if you want the string to show line breaks and do not collapse spaces, you need to change to pre .

Demo:

< hr >

HTML:

  json_stringify  

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf6ec1-3203c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf6ec1-3203c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?