How do I use the JSON manager for files not ending with file extension .JSON?

How do I use the JSON manager for files not ending with file extension .JSON?

131
Basic UserBasic User
131

    May 31, 2017#1

    Hi!

    I have a JSON formatted file, but its file extension is .config and not .json.

    How do I view a .config file in the JSON manager?

    If I rename the file to *.json, then the JSON manager recognizes it and I see the tree view and so on.

    115
    Power UserPower User
    115

      May 31, 2017#2

      You've answered your own question.

      When called by a computer program, the calling program assumes that the provided file is in fact a JSON file and so doesn't care what it is named. Thus there is no restriction on what extension may be used for a JSON file. However for a programmer's text editor like UltraEdit there can be no assumption that any file contains JSON in it without being told. The identification method that the authors of UltraEdit selected was to use the case-insensitive extension .json and when this is used the JSON specific features are activated.

      This is a user-to-user forum not normally monitored by UltraEdit staff. You can request a feature change to allow the user to specify that a file is JSON instead of automatically by the extension. Go to https://www.ultraedit.com/support and fill out the form at the bottom of the page. Code change priorities are driven by number of user requests. It may take quite a while to get enough support for a change.

      131
      Basic UserBasic User
      131

        Jun 01, 2017#3

        Thanks. Sadly, I can't rename the file to .json because it's used by a 3rd party package and must remain named with a file extension of .config

        I'll submit an enhancement request to IDM.

        326
        Basic UserBasic User
        326

          Jun 01, 2017#4

          If you edit the syntax highlighting wordfile wordfiles\json.uew and add CONFIG to the File Extensions it should automatically interpret it as JSON file?

          File Extensions = JSON CONFIG

          131
          Basic UserBasic User
          131

            Jun 01, 2017#5

            There is a way per IDM's Troy:

            Hi Jerry,

            Thank you for your message. If you select "JSON" in the status bar where "No highlighting" [or "XML"] is shown, then this file should be highlighted as a JSON file, and you should then be able to use the JSON manager to parse this file.

            Thanks, Troy

              Jun 01, 2017#6

              hugov wrote:If you edit the syntax highlighting wordfile wordfiles\json.uew and add CONFIG to the File Extensions it should automatically interpret it as JSON file?

              File Extensions = JSON CONFIG
              I tried this, but it didn't work. It would have been too broad for my preference anyway.

              Manually choosing the view type from the status bar is perfect for my use case.

              6,686585
              Grand MasterGrand Master
              6,686585

                Jun 01, 2017#7

                ForceRs, I suppose you have edited the wrong json.uew by editing the file in wordfiles subdirectory in program files directory of UltraEdit or you have forgotten to remove file extension CONFIG from wordfile for XML files.
                • Open Advanced - Settings/Configuration - Editor Display - Syntax Highlighting.
                • Select language JSON if not already preselected because active file is syntax highlighted with that language.
                • Click on button Open.
                • Select next language XML.
                • Click on button Open.
                • Close the configuration dialog with button Cancel.
                • Append at end of first line of json.uew the file extension CONFIG (interpreted case-insensitive) or insert this file extension before JSON.
                • Remove from first line of xml.uew the file extension CONFIG.
                • Save and close both wordfiles.
                Now open the *.config file using JSON format. It should be automatically syntax highlighted as JSON file indicated in status bar. Restart UltraEdit if the indicated language in status bar is still XML.

                Using CONFIG as file extension was definitely no good idea by the developer of the application as it does not give any other application or a person an information about format of the file containing configuration data.

                Another method to highlight just appname.config as JSON file by default and all other *.config files as XML files working only if the file name does not contain a space character is using a file name specific syntax highlighting.
                • Open Advanced - Settings/Configuration - Editor Display - Syntax Highlighting.
                • Select language JSON if not already preselected because active file is syntax highlighted with that language.
                • Click on button Open.
                • Close the configuration dialog with button Cancel.
                • Replace File Extensions = JSON at end of first line of json.uew by File Names = appname.config (case-insensitive interpreted name of the file without path).
                • Use Save As and save the file for example as json_appname.uew into same directory as json.uew, i.e. %APPDATA%\IDMComp\UltraEdit\wordfiles.
                • Close the new wordfile json_appname.uew and restart UltraEdit.
                Now open the appname.config file using JSON format. It should be automatically syntax highlighted as JSON file indicated in status bar.
                Best regards from an UC/UE/UES for Windows user from Austria

                131
                Basic UserBasic User
                131

                  Jun 01, 2017#8

                  Mofi,

                  Thank you!

                  I made a custom json_appname.uew as suggested and it works like a charm. Greatly appreciated.

                  Oh -- and you were correct -- I was editing the program files version of the JSON file, i.e. "C:\Program Files\IDM Computer Solutions\UltraEdit\wordfiles\json.uew", and that's why it failed as I tried to implement hugov's suggestion.

                  1
                  NewbieNewbie
                  1

                    Jul 02, 2017#9

                    I tried this, and it works great for highlighting, either adding my own extension for JSON saving the existing one as a new file and just putting in my own extension.

                    However the JSON manager completely ignores this. It only seems to work if the file is named .JSON. The highlighting is correct - and even using the dropdown worked fine for that. But the JSON manager seems to be separate making this not work at all for me.

                    6,686585
                    Grand MasterGrand Master
                    6,686585

                      Jul 03, 2017#10

                      There is absolutely no need to create a second JSON syntax highlighting wordfile if just one more file extension needs to be recognized for syntax highlighting JSON files with a different file extension than JSON. The additional file extension must be just added to json.uew file according to the steps of first list in my previous post.

                      I have just found out with some tests with UE v24.10.0.24 that a file is parsed for JSON manager view if its file extension is JSON independent on syntax highlighting of the file.

                      When deleting json.uew wordfile or renaming its file extension while UE is not running and then starting UE with loading a *.json file, the file is not syntax highlighted, but JSON manager view shows the data in tree view.

                      On the other hand on appending for example file extension TXT on first line of wordfile json.uew and opening a *.txt file containing JSON structured data, the file is syntax highlighted as JSON file, but is not JSON parsed and therefore JSON manager view remains empty.

                      However, clicking with secondary (right) mouse button into JSON manager view to open its context menu and clicking with primary (left) mouse button on context menu item Parse document results in JSON parsing of active document independent on applied syntax highlighting.

                      I have sent a feature request by email to IDM support suggesting to run JSON parser not only on *.json files automatically (according to JSON related settings in configuration), but also on all files which are syntax highlighted with a language having language marker JSON_LANG. An alternate suggestion would be adding to JSON configuration dialog an edit field on which users can specify a semicolon separated list of file extensions and file names like .json;.config;ApplicationName.cfg. Each name of a file (file name + file extension) ending case-insensitive with one of those strings should be interpreted as JSON file. I have added this second suggestion into same feature request email. Of course my request is just one of millions of users. So it is necessary that other users (especially those representing more licenses than 1) request such an enhancement for automatic JSON parsing, too.

                        Apr 08, 2019#11

                        I want to add information about a silent enhancement implemented in UltraEdit for Windows v26.00.0.48 and UEStudio v19.00.0.24. JSON data inside a script element of an HTML syntax highlighted file with attribute type="application/json" or type="application/ld+json" are automatically JSON syntax highlighted. The start and end tag of the script element with JSON data as value are HTML syntax highlighted.
                        Best regards from an UC/UE/UES for Windows user from Austria