-1

I'd like to have multiple values output the same object in a key array.

"myobject": {
  ["foo", "bar"]: "foobar"
}

Is there a way in javascript to use an array as a key in a key array, so if I were to input either "foo" or "bar", it would give me "foobar"?

2 Answers2

0

No, json.org, the key must a string

Mitoxys
  • 297
  • 3
  • 8
-2

You could make it a string which just happens to be an array when passed through eval(), but it's probably not an ideal data structure.

mike.k
  • 3,277
  • 1
  • 12
  • 18