Extract the JSON data from the POST request in Lua



  • I'm doing a load test. I'm writing a screenplay in Load Impact in Lua. The problem was: There's a request for POST. In this request, data in JSON are available in the format: Ответ в POST запросе

    http://myscreenshot.info/i/0006/612111450699792884956751912612.png

    Question: How do I get these data? For example, I need the local variable to assign the value of the ID.



  • No checks on nil:

    local response = http.post(url)   -- или response = http.request("POST", url ...    
    local j = json.parse( response.body )
    print(1, j.Id )
    -- или так 
    print(2, response.body:match('"Id":"(.-)"') )
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2