I'm attempting to retrieve keys from a dictionary using JavaScript.
The user uploads a .json file containing the dictionary, and I want to display the keys from that uploaded dictionary. It's important to note that only .json dictionaries can be uploaded, and they are parsed into a variable holding the dictionary.
For instance, let's consider the following dictionary
var dict = [
{key1: "hello", key2: "world"},
{key1: "test", key2: "testy test"}
]
and my goal is to obtain the key1 and key2 values, perhaps as a string array like:
var keys = ["key1", "key2"]
.
Is this feasible? If so, how should I approach it?