일반적으로 javascript 에서 객체를 표현할때는 json 형태로 표시합니다
var items = []; //아이템 배열
items.push({“Id”: “0”, “Name”: “James”, “Address”: “Seoul”}); //배열에 object 추가
items.push({“Id”: “1”, “Name”: “Elena”, “Address”: “Seoul”});
items.push({“Id”: “2”, “Name”: “David”, “Address”: “Seoul”});
//하나의 객체가 필요하다면 배열을 돌아서 해당 값을 찾으면 됩니다.
for(var i=0; i < items.length; i++) {
if (items[i].Id === “1”) {
console.log(items[i]);
}
}
Dictionary 라고 쓰신 부분에 대해서 부연 설명을 드리자면,
Dictionary 와 같은 Key Value 형태는 따로 지원하지 않으나, 위의 객체 형식을 빌려 구성이 가능합니다.
var items = {}; //아이템 object
items[“0”] = {“Id”: “0”, “Name”: “James”, “Address”: “Seoul”};
items[“1”] = {“Id”: “1”, “Name”: “Elena”, “Address”: “Seoul”};
items[“2”] = {“Id”: “2”, “Name”: “David”, “Address”: “Seoul”};
if (“0” in items) { //items 에 "0"이라는 property 가 있다면
}
위 구조에 대해서는 C# 에서 List 를 통해 객체를 만드신 다음에 JsonConvert.SerializeObject로 해당 객체를 Json으로 변환해보시면 이해가 빠르실 겁니다.