How to check if JSON Object Key's Value is Key Object?

{
"key_one": {
    "key_two": {
        "value": 1,
    }
}

How to check if the value of key_one is an object, not value it self?

>Solution :

typeof input.key_one will tell you if it is an object:

const input = {
  "key_one": {
    "key_two": {
      "value": 1
    }
  }
};

console.log(typeof input.key_one);

Output:

object

Leave a Reply