Array<int> to var


#1

Hi all,

is there a way to store an Array into a var? What I want to do is eventually store the Array’s values into a JSON.
What would be a “correct” way of doing this, as I also want to read that data from the JSON file later ?

-N


#2

A var can store an Array of vars, which can then be integers.
There is also a convenience method var::append (var):

var object;
object.append (1);
object.append (5);
object.append (3);

Array<var>* array = object.getArray();
for (int num : *array)
    DBG ("number: " + String (num));

#3

Thank you very much daniel, it works fine for what I want to do!
Cheers!

-N


#4

You’re welcome :slight_smile: