2014-03-29 5 views
1

다음은 출력 인 Json Array입니다. 그리고이 배열에서 이름과 설명 만 검색하려고합니다. 결과를 HTML 페이지 내의 테이블에 넣길 원합니다. 도와주세요.JSON 배열에서 특정 데이터를 검색하는 방법은 무엇입니까?

(
      [columnId] => 258f2200948711e3b4507b78fb18a9a7 
      [columnName] => To-do 
      [tasksLimited] => 
      [tasks] => Array 
       (
        [0] => stdClass Object 
         (
          [_id] => 5f4d17eeff71cf48f8cf033db78c5755 
          [name] => test 
          [description] => 
          [color] => yellow 
          [columnId] => 258f2200948711e3b4507b78fb18a9a7 
          [totalSecondsSpent] => 0 
          [totalSecondsEstimate] => 0 
         ) 

        [1] => stdClass Object 
         (
          [_id] => ed30db48426da335d7b232d2d8c5b4f0 
          [name] => Write report 
          [description] => 
          [color] => red 
          [columnId] => 258f2200948711e3b4507b78fb18a9a7 
          [totalSecondsSpent] => 0 
          [totalSecondsEstimate] => 0 
         ) 

        [2] => stdClass Object 
         (
          [_id] => ed30db48426da335d7b232d2d8e51eee 
          [name] => szxfasdfasdf 
          [description] => 
          [color] => yellow 
          [columnId] => 258f2200948711e3b4507b78fb18a9a7 
          [totalSecondsSpent] => 0 
          [totalSecondsEstimate] => 0 
         ) 



       ) 

     ) 
+0

JSON이 아닙니다. [example here] (http://json.org/example.html)를 찾을 수 있습니다. –

+0

그런 다음. 그것의 배열을 말하는 것을 의미합니까? – user3386765

+0

어디에서 JSON 값을 얻을 수 있습니까? – Lepanto

답변

0

JSON에서 원하는 요소에 액세스하려면 루프를 거쳐야합니다.

tasks_details

var tasks_details = your_array['tasks'], 
     tasks_no = tasks_details.length; 
    for (var i = 0; i < tasks_no; i++) 
    { 
     $('.your_table').append('<tr><td>' + tasks_details[i].name + '</td>\ 
<td>' + tasks_details[i].description + '</td></tr>'); 
    } 

샘플 코드는 이전처럼 될 것이다라는 개체, 이제 테이블을 채우는 방법 선택의 여지가 남아 있다고 말할 수 있습니다.

+0

먼저 감사드립니다. 이 "your_array"의 의미는 무엇입니까? – user3386765

관련 문제