This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

api, nesting too deep
#2
Nesting limit is needed to prevent recursive tables. Without this limit such code will cause an infinite loop when logging:
Code:
t = {}
t.t = t
log(t)

You can use an external JSON viewer to find which fields you need from the whole JSON table. Keep in mind that Lua indexing starts from 1 instead of 0. This will log the relevant data:
Code:
require('json')
require('socket.http')

url = 'https://ergast.com/api/f1/current/last/results.json'
data = socket.http.request(url)
data = json.pdecode(data)

if type(data) == 'table' then
  log(data.MRData.RaceTable.Races)
end
Reply


Messages In This Thread
api, nesting too deep - by Dré - 30.10.2022, 15:40
RE: api, nesting too deep - by admin - 31.10.2022, 06:57
RE: api, nesting too deep - by Dré - 31.10.2022, 19:41

Forum Jump: