JS format JSON

如何用 Javascript format JSON
解決方法:
我們可以使用JSON.stringify 來 format
e.g.

var c = {a : "test", b:{ data: "asdada"}}

JSON.stringify(c, null, 4)
"{
    "a": "test",
    "b": {
        "data": "asdada"
    }
}"

Hope you find it useful

Chi Yau
Chi Yau
Software Developer

Intererest to share knowledge / experience

comments powered by Disqus