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.

Json tables
#1
When communicating with API's, we often get replys with som intricate system of data in tables.
For instance, one reply would be: responce["response"][1]["more_response"],  responce["response"][2]["more_response"],  responce["response"][xx+]["more_response"].
Is there any way to just show how many "[xx]" there are in the responce table? as this is dynamic, the rest of my code is dependent of knowing this.

Thanks in advance.
Reply
#2
Use the length operator (#): https://www.lua.org/manual/5.1/manual.html#2.5.5
Or you can use ipairs to go through the whole table: https://openrb.com/docs/lua.htm#ipairs
Reply


Forum Jump: