Monday, 28 November 2016

parsing - How to reformat JSON in Notepad++?



I need Notepad++ to take a json string from this




{"menu": {"id": "file","value": "File","popup": {"menuitem": [{"value": "New", "onclick": "CreateNewDoc()"},{"value": "Open", "onclick": "OpenDoc()"},{"value": "Close", "onclick": "CloseDoc()"}]}}}


to this...



{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [

{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}


I looked around at all the TextFX options but couldn't find anything that worked.


Answer





Update:



As of Notepad++ v7.6, use Plugin Admin to install JSTool per this answer




INSTALL



Download it from http://sourceforge.net/projects/jsminnpp/ and copy JSMinNpp.dll to plugin directory of Notepad++. Or you can just install "JSTool" from Plugin Manager in Notepad++.




New Notepad++ install and where did PluginManager go? See How to view Plugin Manager in Notepad++



{
"menu" : {
"id" : "file",
"value" : "File",
"popup" : {
"menuitem" : [{
"value" : "New",
"onclick" : "CreateNewDoc()"

}, {
"value" : "Open",
"onclick" : "OpenDoc()"
}, {
"value" : "Close",
"onclick" : "CloseDoc()"
}
]
}
}

}


enter image description here
Tip: Select the code you want to reformat, then Plugins | JSTool | JSFormat.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...