Announcement

Collapse
No announcement yet.

read json without nsjson

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

  • read json without nsjson

    can we read a JSON file in NSIS without using nsjson plugin?

  • #2
    NSIS does not have native JSON support, you are stuck with the plug-in.

    If the file is really small and simple you might be able to use the NSIS file and string instructions but I don't really recommend it.
    IntOp $PostCount $PostCount + 1

    Comment


    • #3
      I am sorry for the basic questions. I have this in my json file
      {
      "BLD_BRH" : "****",
      "RLS_STR" : "****",
      "RLS_FIXED" :
      }
      i am setting this nsJSON::Set /file $EXEDIR\manifest.json . but I just need to read BLD_BRH and RLS_FIXED. I don't see anything here in examples

      Comment


      • #4
        PHP Code:
        Section
        InitPluginsdir
        FileOpen 
        $"$PluginsDir\temp.txt" w
        FileWrite 
        $'{"BLD_BRH" : "1234","RLS_STR" : "5678","RLS_FIXED" : "invalid example"}'
        FileClose $0
        nsJSON
        ::Set /file "$PluginsDir\temp.txt"

        nsJSON::Get "BLD_BRH" /end
        Pop 
        $0
        MessageBox mb_ok 
        $0
        SectionEnd 
        IntOp $PostCount $PostCount + 1

        Comment


        • #5
          will check this out..... thank you

          Comment


          • #6
            I don't want to write anything. there is already a file that I just need to read.

            {
            "BLD_BRH" : "****",
            "RLS_STR" : "****",
            "RLS_DFT" : [
            [

            ],

            ],
            "RLS_FIXED" :"***",
            }

            Section
            ClearErrors
            Push $0
            nsJSON::Set /file "$EXEDIR\eg.json"

            nsJSON::Get "RLS_STR" /end
            Pop $0
            MessageBox mb_ok $0
            SectionEnd

            it shows blank

            Comment


            • #7
              trailing commas are not allowed in JSON
              IntOp $PostCount $PostCount + 1

              Comment


              • #8
                even without that, no difference. it is the same blank message

                Comment


                • #9
                  There is known bug in this plug-in, it does not support empty arrays.
                  IntOp $PostCount $PostCount + 1

                  Comment


                  • #10
                    my actual file is not empty... it looks like i have to use file and string instructions

                    Comment

                    Working...
                    X