웹프로그래밍

Global It Leader!!


jQuery


 
 

jSON 배열 참조하는 예제

페이지 정보

작성자 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 1,225회 작성일 22-03-27 09:57

본문

var people = {
  "programmers": [
    {
      "firstName": "Brett",
      "lastName": "McLaughlin",
      "email": "brett@newInstance.com"
    },
    {
      "firstName": "Jason",
      "lastName": "Hunter",
      "email": "jason@servlets.com"
    },
    {
      "firstName": "Elliotte",
      "lastName": "Harold",
      "email": "elharo@macfaq.com"
    }
  ],
  "authors": [
    {
      "firstName": "Isaac",
      "lastName": "Asimov",
      "genre": "science fiction"
    },
    {
      "firstName": "Tad",
      "lastName": "Williams",
      "genre": "fantasy"
    },
    {
      "firstName": "Frank",
      "lastName": "Peretti",
      "genre": "christian fiction"
    }
  ],
  "musicians": [
    {
      "firstName": "Eric",
      "lastName": "Clapton",
      "instrument": "guitar"
    },
    {
      "firstName": "Sergei",
      "lastName": "Rachmaninoff",
      "instrument": "piano"
    }
  ]
}

그렇다면 이런 식으로 호출해야 하는 것이다.

people.programmers[0].lastName;
people.authors[1].genre            // 값은 "fantasy"
people.musicians[3].lastName       // 값은 Undefined. 이것은 4번째 엔트리를 가리키며 거기엔 아무 것도 없다.
people.programmers.[2].firstName   // 값은 "Elliotte"

댓글목록

등록된 댓글이 없습니다.

전체 142
게시물 검색
jQuery 목록
번호 제목 글쓴이 조회 날짜
142 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 389 07-06
141 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 618 01-05
140 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 706 12-07
139 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1230 03-31
138 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1237 03-28
열람중 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1226 03-27
136 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1653 03-27
135 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1217 03-27
134 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1253 03-27
133 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1526 03-26
132 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1239 03-26
131 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1389 03-26
130 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 2666 03-26
129 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1867 03-26
128 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1428 03-26
127 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1609 03-26
126 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1857 03-26
125 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1255 03-26
124 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1189 03-26
123 no_profile 운영자 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 1348 03-26