Announcement

Collapse
No announcement yet.

HTTP.Submit, JSON, Table

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

  • HTTP.Submit, JSON, Table

    I'm using the HTTP.Submit to call a webservice that returns its data in a JSON data format.

    Can anyone recommend a lua script or utility for Setup Factory that'll convert the JSON data format into a lua table?

    Thanks.

  • #2
    See here: http://lua-users.org/wiki/JsonModules

    Ulrich

    Comment


    • #3
      Originally posted by Ulrich View Post
      See here: [url]http://lua-users.org/wiki/JsonModules[/url
      Thanks.

      However I'm struggling to get something to work. I opted for this module as it's pure lua.

      I added the file to my project via Resources -> Script Files and then added some test code to the On Startup action. No matter what I do with code below I get errors when the installer runs as follows:

      On Startup, Line 16: module 'dkjson' not found:
      no field package.preload['dkjson']
      etc etc
      This is my sample code I'm trying to test.

      Code:
      local mytext = [[
      {
        "iType": 99,
        "iSerial_No": 1600,
        "sName": "Test Company",
        "sKey": "xxxx",
        "iUsers": 4,
        "sMessage": "ok"
      }
      ]];
      
      
      Dialog.Message("MyText", mytext );
      
      local json = require("dkjson");
      
      local mytable, pos, err = json.decode(mytext, 1, nil);
      if err then
          Dialog.Message("Error", err);
      else
          for k, v in pairs(mytable) do
              Dialog.Message("Table Item", k .. "=" .. v);
          end -- for
      end
      
      
      Application.Exit();
      Could you please help me with this?

      Comment


      • #4
        Originally posted by tbs(apc) View Post
        I added the file to my project via Resources -> Script Files and then added some test code to the On Startup action. No matter what I do with code below I get errors
        Add the Lua module as a Primer File instead, so it will be placed next to the installer runtime (irsetup.exe). This will allow the module to be loaded correctly with require().

        Ulrich

        Comment


        • #5
          Originally posted by Ulrich View Post
          Add the Lua module as a Primer File instead, so it will be placed next to the installer runtime (irsetup.exe). This will allow the module to be loaded correctly with require().
          Thank you for your suggestion Ulrich. My sample code now works. :yes

          Comment

          Working...
          X