Find by key deep in a nested array

后端 未结 17 1312
礼貌的吻别
礼貌的吻别 2020-11-22 15:41

Let\'s say I have an object:

[
    {
        \'title\': \"some title\"
        \'channel_id\':\'123we\'
        \'options\': [
                    {
                 


        
17条回答
  •  情歌与酒
    2020-11-22 15:54

    What worked for me was this lazy approach, not algorithmically lazy ;)

    if( JSON.stringify(object_name).indexOf("key_name") > -1 ) {
        console.log("Key Found");
    }
    else{
        console.log("Key not Found");
    }
    

提交回复
热议问题