admin管理员组文章数量:1307248
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?
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?
Share Improve this question edited Dec 16, 2021 at 9:50 Mark Rotteveel 109k229 gold badges156 silver badges220 bronze badges asked Dec 14, 2021 at 3:21 gkeenleygkeenley 7,41816 gold badges77 silver badges178 bronze badges 1- this process is called JSON beautify and is available in almost all popular programming languages – tsamridh86 Commented Dec 14, 2021 at 3:29
3 Answers
Reset to default 4I 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 ment but I don't have many reputations
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)
本文标签: javascriptHow to convert singleline JSON to multilineStack Overflow
版权声明:本文标题:javascript - How to convert single-line JSON to multi-line? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741809685a2398718.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论