How can i navigate through the json?

后端 未结 3 1513
孤街浪徒
孤街浪徒 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:55

    The object is an object, not an array, and it doesn't have a property called 0.

    To get rootLayout:

    obj.rootLayout
    

    However, rootLayout is a string, not an object. It doesn't have an id. The first item in the layoutDescriptions array does.

    obj.layoutDescriptions[0].id
    

提交回复
热议问题