title: Problems with decoding JSON in lua
body: <p>I have the following code:</p>
  <pre><code>PerformHttpRequest('http://ossie.dk/API/verify.json',function(err, text, headers)
      local r=json.decode(text)
      for s,t in pairs(r.servers)do
           print(t)
      end
  end,&quot;GET&quot;,&quot;&quot;,{})
                 
  </code></pre>
  <p>My problem is, when decoding the things from the verify.json i keep receiving either this error: bad argument #1 to 'strfind' (string expected, got nil) or that what trying to do a key, value for is not a table. Im really lost at this point, spend so much time on this thing. I think the whole problem is how the JSON is set up. It needs to be a string, but also a table that I can use for my key, value pairs later on so I can get all the info from it. I hope this makes some sort of sence.</p>
  <p>The scripting error is coming from here:</p>
  <pre><code>local function scanwhite (str, pos)
    while true do
      pos = strfind (str, &quot;%S&quot;, pos)
      if not pos then return nil end
      local sub2 = strsub (str, pos, pos + 1)
      if sub2 == &quot;\239\187&quot; and strsub (str, pos + 2, pos + 2) == &quot;\191&quot; then
        -- UTF-8 Byte Order Mark
        pos = pos + 3
      elseif sub2 == &quot;//&quot; then
        pos = strfind (str, &quot;[\n\r]&quot;, pos + 2)
        if not pos then return nil end
      elseif sub2 == &quot;/*&quot; then
        pos = strfind (str, &quot;*/&quot;, pos + 2)
        if not pos then return nil end
        pos = pos + 2
      else
        return pos
      end
    end
  end
  </code></pre>
  <p>My current JSON looks like this:</p>
  <pre><code>{   
      { &quot;servers&quot;: 
          &quot;ip&quot;: 
          [
              &quot;144&quot;,
              &quot;155&quot;,
              &quot;166&quot;
          ]
      }
  }
  </code></pre>
  <p>BTW I have tried changing</p>
  <pre><code>r.servers
  </code></pre>
  <p>with</p>
  <pre><code>r.ip
  </code></pre>
  <p>then it gives this: invalid vector field: ip</p>
  <p>If I just do</p>
  <pre><code>for k,v in pairs(r) do
  </code></pre>
  <p>It will give me this error:</p>
  <pre><code>Table expected, got string
  
  </code></pre>
  <p>Im using the JSON library from FiveM.</p>
  <p>If you  have some questions or dont understand what I mean feel free to ask in the comments.</p>