Community
    • Login

    .json format not recognized on load, not present in Style Configurator's Languages list

    Scheduled Pinned Locked Moved General Discussion
    8 Posts 3 Posters 115 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      InjAnnuity1
      last edited by

      I’m a C++ and Python user, starting to use JSON rather consistently. I’ve noticed for a long time, now, that Notepad++ does not seem to recognize JSON format text, even when loaded directly as a .json file. It doesn’t matter whether I load it from the command line, or from within Notepad++.

      Moreover, while JSON appears in the Languages menu, it does not appear in the Style Configurator’s list of Languages. I suppose I could add it to Javascript’s list of file extensions, but if that was the intended method of support, it would probably be there already, and would not appear in the Languages menu.

      I wonder if I’m doing anything wrong, perhaps misconfigured something; or whether this is the intended behavior of Notepad++. Or perhaps a plugin is interfering? Is anyone else seeing this behavior?

      I’m using Notepad++ version 8.8.1 (64-bit) under Windows 10. I also have the following plugins installed (all up-to-date):
      Customize Toolbar v5.3
      JSON Tools v8.3.1
      Mime tools v3.1
      Npp Converter v4.6
      NppExport v0.4
      XML Tools v3.1.1.13

      Yes, I’ve searched this Forum for this particular question. If it’s here, I’ve definitely missed it.

      Best regards,
      -Phil

      Mark OlsonM PeterJonesP 2 Replies Last reply Reply Quote 1
      • Mark OlsonM
        Mark Olson @InjAnnuity1
        last edited by

        @InjAnnuity1
        This is a strange problem, and I have a couple of questions that might narrow it down:

        1. What theme are you using? If you’re using a rarely used theme, maybe the person who created it forgot to add styles for JSON.
          • There is at least one theme for which this is true, I think.
          • If you’re using Default (stylers.xml), this should not be happening, unless:
        2. Are you using a portable install or an AppData install? If you’re using an AppData install, and you replaced a very old (or weirdly configured) version of Notepad++ with v8.8.1, your new Notepad++ installation will not overwrite a lot of config settings from an old installation. Maybe something weird happened with the old version and the new version didn’t fix it.
        3. What was the first version of Notepad++ that you noticed this issue with? What was the last version of Notepad++ that you didn’t notice this issue with?
        1 Reply Last reply Reply Quote 3
        • PeterJonesP
          PeterJones @InjAnnuity1
          last edited by

          @InjAnnuity1 ,

          Notepad++ does not seem to recognize JSON format text

          Do you mean Notepad++ is not syntax highlighting the JSON, or do you mean that it’s completely not recognized (that is, the status bar says “Normal Text File” instead of “JSON”, and/or the Language menu has None (normal text) selected instead of J > JSON).

          If it’s completely unrecognized, then probably something else has hijacked the .json extension. Otherwise, as I explain further down (and @Mark-Olson suggested), your theme might not have it or might be out of date.

          while JSON appears in the Languages menu, it does not appear in the Style Configurator’s list of Languages

          The list in the Languages menu depends on the compiled Notepad++ executable. The list in the Style Configurator depends on your theme (config-file based).

          My best guess is that your theme is out-of-date (or has never implemented JSON for whatever reason; most themes are not maintained). What theme are you currently using? And if you switch to stylers.xml or Dark Mode Default.xml, does it work? (Even if those do not, it might be because you’ve had Notepad++ for so long that even those two themes don’t have it, because N++ didn’t overwrite them during updates.)

          The user manual has a section on keeping stylers/themes up to date

          Assuming my guess is correct, and your theme doesn’t support JSON yet, you can manually fix it:

          1. Close all instances of Notepad++ and run one instance (required to be able to edit config files)
          2. Open C:\Program Files\Notepad++\stylers.model.xml (assuming normal installation of Notepad++; if you have `notepad++.exe
          3. Depending on your theme (stylers.xml vs a named Theme), open whichever of the following exists and is appropriate:
            • %AppData%\Notepad++\stylers.xml
            • %AppData%\Notepad++\themes\THEME NAME.xml
            • C:\Program Files\Notepad++\themes\THEME NAME.xml
          4. Look for the name=“json” section in stylers.model.xml, and paste that whole section of XML into your stylers/themes file from step 3
          5. Save your stylers/themes file, and exit Notepad++ and restart
          6. It should syntax highlight JSON files now.

          The Manual also links to a script I wrote for the PythonScript plugin, which can automate that… but getting PythonScript installed and working is more than many users like dealing with.

          (@Mark-Olson beat me to some, but not all, of these points, while I was writing them; sometimes, being less wordy and giving fewer instructions than I do can be useful. ;-) )

          I 1 Reply Last reply Reply Quote 3
          • Mark OlsonM
            Mark Olson
            last edited by

            By the way, in case anyone is wondering:
            JsonTools v8.3.1 (which @InjAnnuity1 has installed) hijacks the status bar of Notepad++ to display more information about the file (for example, how many syntax/schema validation errors were detected), but does not do anything to the Style Configurator or the Languages menu.

            1 Reply Last reply Reply Quote 4
            • I
              InjAnnuity1 @PeterJones
              last edited by

              @PeterJones said in .json format not recognized on load, not present in Style Configurator's Languages list:

              Do you mean Notepad++ is not syntax highlighting the JSON, or do you mean that it’s completely not recognized (that is, the status bar says “Normal Text File” instead of “JSON”, and/or the Language menu has None (normal text) selected instead of J > JSON).

              In fact, it’s all of the above. The status bar says “Normal text file”. The Language menu has “None (normal text” selected. And there is no syntax highlighting.

              I am using the Default (stylers.xml) theme, but I have some Global overrides for font style, choice, and size.

              Thanks for the pointer into the users’ manual! I’ve been using Notepad++ for years, so it’s quite possible that my theme file pre-dates JSON. I will take a closer look and try to resolve issues that way.

              Best regards,
              -Phil

              PeterJonesP 1 Reply Last reply Reply Quote 1
              • PeterJonesP
                PeterJones @InjAnnuity1
                last edited by PeterJones

                @InjAnnuity1,

                One more question: does your file end in .json , or does it use some other extension? Because if it doesn’t end in .json, then you will have to tell Notepad++ to associate that with JSON (after you’ve fixed stylers.xml)

                In fact, it’s all of the above. The status bar says “Normal text file”. The Language menu has “None (normal text” selected. And there is no syntax highlighting.

                If your file extension is .json, that means that not only is your AppData copy of stylers.xml out of date compared to the installation’s stylers.model.xml, but your AppData copy of langs.xml is out of date compared to the installation’s langs.model.xml (because langs.xml is where Notepad++ keeps the list of default extensions for each language type). You will need to update both.

                I have some Global overrides for font style, choice, and size.

                Do you understand the difference between “Global override” and “default style”? Because the first should almost never be used: see “Global override” in the User Manual

                I 1 Reply Last reply Reply Quote 2
                • I
                  InjAnnuity1 @PeterJones
                  last edited by

                  @PeterJones
                  I’ve copy-and-pasted the “json” section from stylers.model.xml to my stylers.xml. And that almost was enough.

                  Yes, the file extension is “.json”. So, following your suggestion, I’ve updated langs.xml in a like manner, and that seems to have done the trick!

                  I will try “default style” in place of “Global override”, and see how it goes.

                  Thanks for the great help!
                  -Phil

                  I 1 Reply Last reply Reply Quote 2
                  • I
                    InjAnnuity1 @InjAnnuity1
                    last edited by

                    “default style” is working fine for my purposes.

                    I will propagate these configuration changes to any other old installations I may have.

                    Thanks to all for the very effective help!

                    -Phil

                    1 Reply Last reply Reply Quote 1
                    • First post
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors