-2
{
    pet: {
        "0.628": 92694.5,
        "8739.836": 96391.94
    },
    try: { 
        //same
    }
}

When I specify the key, I get the values but i am trying to read all the values without knowing the keys. I have even tried regex, but nothing seems to be working. As you can see i am fairly new. So sorry if this was a stupid question.

console.log(data.pet) // Gives [Object Object]
console.log(data.pet["0.628"])//Gives the value
console.log(data.pet[0])//Gives undefined
J J
  • 3
  • 2

1 Answers1

0

I don't see in what context you'd want to access a json object without knowing the keys. but what you can do is to parse the json file into a javascript object, and call Object.keys() to get the keys of that object