Why devices tags map is an array instead of string

Hi, why device tags are mapped as array instead of string?
For example, when using the device get node and marking “Return tags as an object map instead of an array” option, the tags turn into something like:

tags: {
foo: [‘bar’],
foo2: [‘bar2’]
}

why not:

tags: {
foo: ‘bar’,
foo2: ‘bar2’
}

It’s kinda weird to access the tags using, for example, machine.tags.foo[0] instead of just machine.tags.foo

I agree, it is weird. The reason is because devices – unlike any other resource in Losant – supports multiple values per tag key. Therefore we have to return an array of results for each tag key, even if there is only one value, to maintain a consistent shape.

FYI, Handlebars will stringify those arrays for you when referencing those values in templates, though you will still have to reference each item with an array index when using JavaScript.

Thank you for clarifying this question, Dylan.