Hello
If I’ve built or received a basic table in my squirrel code, is there any way to print out or get all the slots / keys / values in that table?
Thank you,
Dave
Hello
If I’ve built or received a basic table in my squirrel code, is there any way to print out or get all the slots / keys / values in that table?
Thank you,
Dave
OK, to answer my own question partly, on the agent at least, you can run
http.jsonencode(mytable)
to get a string / JSON representation of the table.
On the device you can try:
`
foreach(key,value in myTable)
server.log("key="+key+" value="+value)
`
Note: this only works if the values in your table are (integer, float, boolean, string). If you have nested arrays or tables as values, you’ll need to either:
It’s (probably) not complete, but: https://gist.github.com/rlipscombe/b7008ba42bc5cec90a09dda8199d010c