Announcement

Collapse
No announcement yet.

nsJSON plug-in

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • nsJSON plug-in

    A JSON (JavaScript Object Notation) parser, manipulator and generator plug-in for NSIS. See the readme file for usage and more information.



    Stu

  • #2
    Nice work!
    Please write a short article into wiki (or copy from readme): http://nsis.sourceforge.net/NsJSON_plug-in
    Cool looking installers with custom design: www.graphical-installer.com
    Create Setup Pages easily: www.install-designer.com
    Build installers in Visual Studio 2005-2022: www.visual-installer.com
    or RAD Studio 2009 - 11 Alexandria: www.rad-installer.com

    Comment


    • #3
      very nice, especially since none of the xml plugins worked to my satisfaction and i got the option to use json files for the same purpose. thanks stu!
      NSIS IDE for Atom | NSIS for Visual Studio Code | NSIS for Sublime Text | NSIS.docset

      Comment


      • #4
        can i use it to parse json backup files from firefox (bookmark backup file/places)?
        Greets, Brummelchen

        Comment


        • #5
          If it is valid JSON then yes.

          Stu

          Comment


          • #6
            New version:
            1.0.0.1 - 1st July 2012
            * Fixed parsing of single digit numbers.
            * Fixed Serialize not writing the output file when the stack isn't empty.
            I've tested this version on Chrome's Preferences JSON file.

            Stu

            Comment


            • #7
              New version:
              1.0.0.2 - 15th August 2012
              * Fixed Unicode build parsing and serializing.
              Note the Unicode build still expects ASCII encoded JSON files at the moment. I will perhaps add support for UTF-8 encoded JSON in the future.

              Stu

              Comment


              • #8
                Hey Stu, is it possible to parse floating numbers with comma instead of point?
                Some currencies use it: "1.23" is "1,23"
                Cool looking installers with custom design: www.graphical-installer.com
                Create Setup Pages easily: www.install-designer.com
                Build installers in Visual Studio 2005-2022: www.visual-installer.com
                or RAD Studio 2009 - 11 Alexandria: www.rad-installer.com

                Comment


                • #9
                  You have to wrap the value in quotes so that it will be treated as a string rather than a float. It is not possible any other way as a comma is used as the delimiter between objects and values (whitespace is ignored).

                  Stu

                  Comment


                  • #10
                    New version (with a fair number of changes):
                    1.0.1.0 - 28th August 2012
                    * Added /unicode switch to the Serialize function. Output files for both plug-in builds are now encoded in ANSI by default.
                    * Removed the Parse function in favour of Set /file [/unicode].
                    * Added /type, /key, /exists, /count, /isempty to the Get function.
                    * Added /index switch for referencing nodes by index.


                    Stu

                    Comment


                    • #11
                      Awesome plugin Stu. Any chance of extending it to support multiple json instances open at once?

                      Comment


                      • #12
                        That is already supported kind of. You just need to use Set /file with a node path to load a JSON file into. The only thing you cannot do is serialize a specific node to a file, which is where a change would be necessary. How much do you need multiple instance support (give an example of usage)?

                        Stu

                        Comment


                        • #13
                          I'm using in-memory json to store lots of my own user-specific data rather than tons of global variables.
                          Then I want to open up a program's settings file which is also in json, add a value and resave that settings.json.

                          It's also useful to separate different blocks of data and only serialize the parts I need during debug.

                          I guess the only thing that's really needed is the ability to serialize a specific node.

                          Unless I can find a better solution for my in-memory storage... Actually, thinking about it I could probably use your arrays plugin and do arrays of pointers to arrays using a counter or concatenating names like
                          CarPark0 = array of license plates (e.g. 0=ABC123, 1=DEF456, 2=GHI789)
                          CarPark0_ABC123 = array of that particular car's properties (e.g. Make=ShinyThingsInc, Color=Green)

                          So yeah, it probably isn't necessary to have the json plugin handle more than 1 root json object at a time. I'll just write my own serializer for the arrays.

                          Cheers again for your awesome stuff.

                          Comment


                          • #14
                            I am getting truncated string values when they have spaces:

                            nsJSON::Set `more_stuff` `PSCHED_009_NAME` /value `QoS Packet Scheduler`

                            Results in:

                            "more_stuff": { "PSCHED_009_NAME": QoS }

                            Comment


                            • #15
                              Values are parsed as JSON. If you want quoted strings you must use double quotes around the value:

                              nsJSON::Set `more_stuff` `PSCHED_009_NAME` /value `"QoS Packet Scheduler"`

                              Stu

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎