How to reformat JSON in Notepad++?

前端 未结 21 1635
清酒与你
清酒与你 2020-12-04 04:20

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

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


        
相关标签:
21条回答
  • 2020-12-04 05:07

    The following Notepad++ plugin worked for me as suggested by "SUN" https://sourceforge.net/projects/jsminnpp/

    0 讨论(0)
  • 2020-12-04 05:08

    It worked for me in the latest edition to Notepad using the UniversalIndentGui.

    What I did was under the plugin setting choose Enable Text Auto Update, a window popped up and I selected javascript.

    0 讨论(0)
  • 2020-12-04 05:09

    Notepad 5.8.7 and jsmin 1.7.0.0 works wonderful here.

    Be careful though, found out jsmin eats the comments the hard way (should have read first).

    0 讨论(0)
  • 2020-12-04 05:10

    Your best bet is to use one of the latest versions of Eclipse (I am using Eclipse Galileo J2EE and Eclipse Ganymede J2EE). Create a JavaScript file, then create a variable:

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

    Lastly, hit CTRL+SHIFT+F and voila! You have a nicely indented JSON Object. I, too, am looking for a Notepad++ JSON formatter, and I very well may be forced to develop an Npp plugin some short time in the future.

    0 讨论(0)
  • 2020-12-04 05:11

    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()"
            }
          ]
        }
      }
    }
    

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

    0 讨论(0)
  • 2020-12-04 05:11

    Universal Indent GUI plugin for Notepad++ will turn your sample into:

    {
        "menu" : {
            "id" : "file", "value" : "File", "popup" : {
                "menuitem" : [ {
                    "value" : "New", "onclick" : "CreateNewDoc()";
                }
                , {
                    "value" : "Open", "onclick" : "OpenDoc()";
                }
                , {
                    "value" : "Close", "onclick" : "CloseDoc()";
                }
                ];
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题