user3464111
user3464111

Reputation: 5

Store an array of values to a key in JSON

AM new to JSON and was thinking if i will be able to store an array of values to one among the keys in my JSON object?

like {"a","e","i","o","u"} to a key called vowels?

Upvotes: 0

Views: 55

Answers (1)

damare
damare

Reputation: 201

Yes, what about:

var chars = {vowels : ["a", "o", "u", "i", "e"]};

Now, you access the vowels via

chars.vowels

Note, that an array is defined using [ ] in JS.

Upvotes: 3

Related Questions