Views 28637 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
- JSON : JavaScript Object Notation 의 약어이며,
            자바스크립트 객체 기호법 이라고 한다.

1. 일반 객체
선언방법 : var obj = { key : value, key : value };
사용방법 : obj.key => return value

2. 배열 객체
선언방법 : var obj = [{ key : value, key : value } , { key : value, key : value }];
사용방법 : obj[index].key => return value

- Example -
1. var obj = { agi : '28', name : '메롱'};
    alert(obj.agi); // '28' 경고창을 띄운다.

2. var obj = [{ agi : '28', name : '메롱' } , { agi : '20', name : '바보' } ]
    alert(obj[1].name); // '바보' 경고창을 띄운다.


***********************************************************************
- Tip - (JSON형태의 데이터의 내용을 모르게되는 경우가 발생하는경우 사용해보자)
***********************************************************************
아래 예제는 소스를 분석을 해보면
peoples 객체의 하위를 포함한 모든 객체의 [키, 값, 길이, 객체형태] 를 출력하는 예제이다.

// 예제소스
window.onload = function(){
    var name_1 = "아빠1";
    var name_2 = "아빠2";

    var peoples = [{
        name  : name_1,
        callFn : function(){alert(name_1);},
        childes : {
            name  : "아빠1_아들",
            agi  : "18살"
        }
    },{
        name  : name_2,
        callFn  : function(){alert(name_2);},
        childes : {
            name  : "아빠2_딸",
            agi  : "18살"
        }
    }];

    forLoop(peoples);
};

function forLoop(items){
    for(var item in items){
        if(typeof items[item] == "object"){
            forLoop(items[item]);
        }else{
            alert(item + " / " + items[item]
                + " / " + items[item].length + " / " + typeof items[item]);
        }
    }
}
?

  1. [ios] ViewController Push할 때 애니메이션 효과

    Date2015.10.23 CategoryDevelop Byhooni Views870
    Read More
  2. [ios] NavigationController 에서 왼쪽(back) 버튼 후킹하기

    Date2015.10.23 CategoryDevelop Byhooni Views1180
    Read More
  3. [c] 한글 문자열 출력

    Date2015.11.10 CategoryDevelop Byhooni Views1675
    Read More
  4. [php] 한글 문자열 자르기 (utf-8)

    Date2015.11.10 CategoryDevelop Byhooni Views1317
    Read More
  5. [js] AngularJS 란?

    Date2015.11.26 CategoryDevelop Byhooni Views885
    Read More
  6. [ios] How To Use UIScrollView to Scroll and Zoom Content (Using Objective-C)

    Date2016.03.23 CategoryDevelop Byhooni Views1608
    Read More
  7. [ios] How To Use UIScrollView to Scroll and Zoom Content (Using Swift)

    Date2016.03.23 CategoryDevelop Byhooni Views7323
    Read More
  8. [ios] Did UIScrollView End Scrolling?

    Date2016.04.19 CategoryDevelop Byhooni Views1017
    Read More
  9. [io] Apple Watch, Today Extension 앱ID 설정

    Date2016.04.20 CategoryDevelop Byhooni Views792
    Read More
  10. XE Core 1.8.18 본문 작성시 태그(html) 사라지는 버그

    Date2016.04.21 CategoryDevelop Byhooni Views864
    Read More
  11. [c#] 전자금융보안론 발표/설치 자료(툴바 소스코드)

    Date2016.05.07 CategoryDevelop Byhooni Views0
    Read More
  12. [ios] UUID 생성 + Key Chain 연동

    Date2016.05.13 CategoryDevelop Byhooni Views4661
    Read More
  13. [ios] 기본 네비게이션바의 타이틀, back버튼 위치와 속성 변경

    Date2016.05.16 CategoryDevelop Byhooni Views2085
    Read More
  14. [ios] 웹뷰 history.back() ㅋㄷ

    Date2016.06.27 CategoryDevelop Byhooni Views1899
    Read More
  15. [ios][swift] 초간단 TableView 샘플

    Date2016.06.27 CategoryDevelop Byhooni Views734
    Read More
  16. [ios][swift] 초간단 To-do Memo

    Date2016.06.27 CategoryDevelop Byhooni Views1063
    Read More
Board Pagination Prev 1 ... 45 46 47 48 49 ... 53 Next
/ 53