How to access an array in a JSON object?

后端 未结 8 978
感动是毒
感动是毒 2020-12-15 05:35

I have the following JSON object:

[
    {
        "comments": [
            {
                "created_at": "2011-02-09T14:42:42-08:0         


        
相关标签:
8条回答
  • 2020-12-15 06:24

    the JSON you have coming back is actually an array itself, so...

    dataJS[0].comments[0].created_at
    

    will be 2011-02-09T14:42:42-08:00, etc...

    Both dataJS and comments are arrays, and need indexes to access the appropriate elements.

    0 讨论(0)
  • 2020-12-15 06:26
    console.log(dataJS);
    console.log(dataJS[0].eee1);
    console.log(dataJS[0].comments[0]);
    
    0 讨论(0)
提交回复
热议问题