Note the spaces. Without spaces, it has a length of 95 so 16 used up in spaces.
Question: Is the data really being stored with spaces or is that just the way http.jsonencode() formats the string?
Reason: I’m using an imp005 (need ethernet). Need the agent to store data if it can’t upload to a db server (maybe network outage or other reason). The example table with spaces would allow 9.8hrs of downtime @ 1 record per minute. Without spaces, it would allow 11.5hrs.
The spaces are introduced by http.jsonencode and do not exist in the original data. You may well find, however, that even with the spaces, the jsonencoded form takes up less memory than the original, which includes all the Squirrel VM’s table overhead.
(But if, on the other hand, you have a lot of these tables and many of the keys and values are the same among all of them, the Squirrel representation pools the strings and stores each only once, where the JSON version must store the strings repeatedly.)
It’s also worth noting, if you have many very similar tables, that a table of arrays uses much less memory than an array of tables. So, as it were:
But if you’re planning on using server.save(), where the JSON is an implementation detail, you should (probably) prefer saving the squirrel object, rather than JSON-encoding it yourself. Otherwise you end up with a JSON string encoding a JSON string, which is going to be larger.
Also note that – at some point – we’ll be changing the server.save() format from JSON to something else that’ll have better fidelity with Squirrel types, and will remove some of the arbitrary-looking restrictions on what you can store.