How can i navigate through the json?

后端 未结 3 1572
孤街浪徒
孤街浪徒 2021-01-26 04:07

I have some JSON which I have in a object but I can seem to return the values a sample of the json is as follows.

{
\"rootLayout\":\"main\",
\"layoutDescriptions         


        
3条回答
  •  忘了有多久
    2021-01-26 04:52

    Are you trying to get one of layoutDescriptions with id equals to obj.rootLayout?

    var targetLayout = {};
    for(var i = 0; i < obj.layoutDescriptions.length; i++) {
        if(obj.layoutDescriptions[i].id == obj.rootLayout) {
            targetLayout = obj.layoutDescriptions[i]; break; 
        }
    }
    
    console.log(targetLayout);
    

提交回复
热议问题