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?
CodePudding user response:
Postman has a button "Beautify" in the top right corner. Click it to be happy.
CodePudding user response:
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)
CodePudding user response:
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