Announcement

Collapse
No announcement yet.

nsJSON plug-in

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

  • #46
    I'm also having trouble using the unicode version of the plugin:

    code:
    OutFile "test.exe"
    !define SETTING_UNICODE
    !ifdef SETTING_UNICODE
    Unicode true
    !addplugindir /x86-unicode "./plugins/x86-unicode"
    !else
    Unicode false
    !addplugindir /x86-ansi "./plugins/x86-ansi"
    !endif
    Page instfiles
    Function .onInit
    nsjson::set /tree testTree testNode /value testValue
    nsjson::get /tree testTree testNode /end
    Pop $R0
    MessageBox MB_OK $R0 ; "testValue"
    FunctionEnd
    Section "dummy"
    SectionEnd

    With the ansi version, the message box reads "testValue" as expected, but with the unicode version is just says "t".

    Comment


    • #47
      Originally Posted by Marshallx7 View Post
      I'm also having trouble using the unicode version of the plugin:

      code:
      OutFile "test.exe"
      !define SETTING_UNICODE
      !ifdef SETTING_UNICODE
      Unicode true
      !addplugindir /x86-unicode "./plugins/x86-unicode"
      !else
      Unicode false
      !addplugindir /x86-ansi "./plugins/x86-ansi"
      !endif
      Page instfiles
      Function .onInit
      nsjson::set /tree testTree testNode /value testValue
      nsjson::get /tree testTree testNode /end
      Pop $R0
      MessageBox MB_OK $R0 ; "testValue"
      FunctionEnd
      Section "dummy"
      SectionEnd

      With the ansi version, the message box reads "testValue" as expected, but with the unicode version is just says "t".
      Sounds like you are using the ansi version for both ansi and unicode installers.

      By the way, if the plugins are copied correctly to both '${NSISDIR}\plugins\x86-ansi' and '${NSISDIR}\plugins\x86-unicode', then you don't need to use !addplugindir. 'Unicode True' does that work for you.
      "Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
      NSIS 3 POSIX Ninja
      Wiki Profile

      Comment


      • #48
        Nope, confirmed I am using the correct builds. DLLs are stored in local plugins directory, not in NSISDIR, hence the use of addplugindir. Does this work for you?

        Comment


        • #49
          No it doesn't work for me, it's showing the same as what you are getting.
          "Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
          NSIS 3 POSIX Ninja
          Wiki Profile

          Comment


          • #50
            When something in a ANSI installer is unexpectedly a single character then it is a clear indication that something was not converted from Unicode to ANSI. The other way around could be anything, a plugin mismatch or bug. A missing conversion bug to Unicode usually looks Chinese.
            IntOp $PostCount $PostCount + 1

            Comment


            • #51
              1.1.0.3 - 4th March 2016
              * Fixed crash for the Delete function when specifying a tree/path that
              does not exist.
              * Fixed Unicode build.
              * Added /keys switch to Get function.
              http://nsis.sf.net/File:NsJSON.zip

              I am still working on the process exec code.

              Stu

              Comment


              • #52
                Yep, Unicode works fine now, thanks Stu.

                I have another feature request:
                It would be great if /index accepted negative numbers to get/set/delete from the end of an array/node.
                For example, /index -1 means the last element, /index -2 means the second-last element and so on.

                Right now, this is achieved by getting the count of elements, decrementing, then getting/setting/deleting the required element. A negative index would streamline this process.

                Comment


                • #53
                  1.1.0.5 - 10th August 2016
                  * Empty value keys ("") were not included in serialized JSON.
                  * Serialize function popped one extra value from the stack.

                  1.1.0.4 - 7th June 2016
                  * Fixed incorrect flags used for HTTP requests.
                  * Added support for negative indices.
                  * Added console application execution for input and output.
                  * Added support for asynchronous HTTP requests and console application
                  execution.


                  Stu

                  Comment


                  • #54
                    Output NodePath not cleared when response is empty?

                    Hi Stu,
                    started using nsJSON recently, very nice work!

                    I'm facing an issue using HTTP web requests:
                    code:
                    nsJSON::Set /tree Request /value `{ "Url": "${myURI}", "Verb": "POST", "DataType": "JSON" }
                    nsJSON::Set /tree Response /http Request

                    The REST method I'm calling in the "Url" may have an empty response (e.g. only returns 200 OK).
                    In such case, the returned Response tree has the "Output" node populated with the response from the previous call to another REST method, instead of returning an empty "Output" node.

                    Is this a bug or am I missing something?

                    Thanks
                    Andrea

                    Comment


                    • #55
                      I have uploaded a new version which fixes the issue.



                      Stu

                      Comment


                      • #56
                        I'm having a problem with the latest build where nsJSON::Serialize is leaving the filepath on the stack. I know there was an issue fixed recently where one too many values were popped but now the reverse seems to be true...

                        I suspect that the old code was always popping file, even if it wasn't needed, whereas the new code pushes it back on the stack even if it was needed

                        On a separate note, I have found that doing an http request with Verb=POST and DataType=JSON sends a request where the post data is unicode with Content-Type: application/x-www-form-urlencoded
                        Is there a way to get this to send as UTF-8 with Content-Type: application/json ?

                        Thanks
                        Last edited by Marshallx7; 2 November 2016, 00:20. Reason: extra request

                        Comment


                        • #57
                          How are you supposed to delete a tree? Especially the "default"? tree?

                          nsJSON::Set /value '{ "Input": [ { "test1": false, } ] }'
                          nsJSON:elete /end # <-- Crash on exit!
                          nsJSON::Set /value '{ "Input": [ { "test1": false, } ] }'
                          nsJSON:elete "" /end # <-- Does nothing
                          nsJSON::Set /value '{ "Input": [ { "test1": false, } ] }'
                          nsJSON::Set /value '{}' # <-- "Works"

                          nsJSON::Set /value '[]'
                          nsJSON::Set /value '{ "Input": [ { "test1": false, } ]' # Not valid JSON now?
                          nsJSON::Set /value '{}' # <-- Now it fails
                          nsJSON:elete /tree "" /end # <-- Crash
                          IntOp $PostCount $PostCount + 1

                          Comment


                          • #58
                            Good job!
                            Try this tool: JSON formatter

                            Comment


                            • #59
                              Originally Posted by Anders View Post
                              How are you supposed to delete a tree? Especially the "default"? tree?
                              1.1.1.0 - 21st November 2017
                              * Fixed JSON with syntax errors still being parsed without setting the error flag.
                              * Fixed Set function not replacing the root value if the value was an array.
                              * Fixed Delete function not deleting the root node and tree.


                              Anders, please let me know if this resolves all your issues. Apologies for the wait.

                              This will delete the root node and tree:
                              code:
                              nsJSON:elete /end
                              Stu

                              Comment


                              • #60
                                I'm having a problem with the latest version (1.1.1.0)


                                code:
                                nsjson::Set x /value []
                                nsjson::Get /exists x /end
                                Pop $R0
                                MessageBox MB_OK "$R0" ;yields "no", expected "yes"

                                nsjson::Set x /value [1]
                                nsjson::Get /exists x /end
                                Pop $R0
                                MessageBox MB_OK "$R0" ;yields "yes", as expected

                                To be clear, the previous version of the plugin (1.1.0.9) gives "yes" for the first snippet, as expected.

                                Comment

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