I'm copy-pasting JSON from a server log into Postman. The JSON in the server log is single-line like this:
{"a": 1, "b": 2}
but I want it to be multi-line like this:
{
"a": 1,
"b": 2
}
Is there a way to do this in Postman or elsewhere other than manually?
Postman has a button "Beautify" in the top right corner. Click it to be happy.
You can parse the JSON, then stringify it again:
const json = `{"a": 1, "b": 2}`; const res = JSON.stringify(JSON.parse(json), 0, 2) console.log(res)
I don't know about postman but in VS Code you can format document just " right-click mouse btn in VScode > format document with > JSON Language Feature " although it works only if its fully JSON file not js.
sorry I want to write it in a comment but I don't have many reputations
There are many JSON formatters in the web.
I like this one: https://jsonformatter.curiousconcept.com/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.