This is my JSON file:
{
"Key": "some-key",
"some-key": {
"comLength": 1
},
}
How do I access the comLength value?
I would do this
Considering your object variable is named someObject, you can access it like:
var comLength = someObject["some-key"].comLength
Example:
var someObject = {
"Key": "some-key",
"some-key": {
"comLength": 1
},
}
var comLength = someObject["some-key"].comLength;
console.log(comLength);
You can reference it via the dot notation (.) and the square notation ([]) (the [] notation is mandatory in case of the property key of some-key because of the -)
const obj = {
"Key": "some-key",
"some-key": {
"comLength": 1
}
};
console.log(obj["some-key"].comLength);
console.log(obj["some-key"]["comLength"]);