2012-02-09 5 views
0

내 템플릿을 구문 분석하기 위해보다 체계적인 데이터 배열을 만들어야합니다. 어떻게하면 더 잘 쓸 수 있습니까? 나는 배열과 같은 배열을 그룹화하고 싶습니다 : [array], [array] ... mvData : [array], ... array ...자바의 다차원 배열을위한 리소스

나는되고 싶다. vars.globalVars [2]/mvData.Revenue 등을 사용할 수 있습니다.

저는 아직 배열에 대해 배우고 있습니다. 모든 데이터는 단지 비유입니다 ..

vars = ['Game', 'Player', 'Social Stats']; 
mvData = ['22,359', '16,235', '10,938', '5,305', '12,588', '6,583'];  
evoMetric = ['Registered Players', 'Started Missions', 'Objects Bought', 'Combats', 'Guerrilla Combats', 'Teams Created', 'Guerillas created']; 
playerMetric = ['playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric']; 
socialMetric = ['Invitations', 'Gifts', 'Combats', 'Comic', 'Trailer', 'Illustration', 'Mission', 'Levels']; 
+1

어레이가 올바른 해결책이 아닙니다. 개체를 사용하십시오. –

답변

1

, 당신은 쉽게 만들 수 있습니다 복잡한 데이터 구조. 다음은 유효한 객체입니다.

myObject = {"property1": "value1", 
      "property2": "value2", 
      "subobject": {"subproperty": "subvalue"}, 
      "aubarray": ["element1", "element2", {"innerobjectkey": "innerobjectvalue"}]}; 
+0

감사합니다! 웬일인지 모든 검색은 나를 위해 충분하지 않았다. – iamwhitebox

0

당신은 당신은 객체로를 구성 할 수이

var MyArray = ['some text',[second dimension array],[second dimension array,[third dimension array] ]]; 
+0

두 번째 차원 배열을 호출하면 다음과 같이됩니다. MyArray [1] [0], 다음과 같은 3 차원 배열 : MyArray [2] [1] [원하는 인덱스] 더 많은 대괄호를 사용합니다. – zero

0

처럼 할 수있는 : 자바 스크립트에서

{ 
vars: ['Game', 'Player', 'Social Stats'], 
mvData: ['22,359', '16,235', '10,938', '5,305', '12,588', '6,583'], 
evoMetric: ['Registered Players', 'Started Missions', 'Objects Bought', 'Combats', 'Guerrilla Combats', 'Teams Created', 'Guerillas created'], 
playerMetric: ['playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric', 'playerMetric'], 
socialMetric: ['Invitations', 'Gifts', 'Combats', 'Comic', 'Trailer', 'Illustration', 'Mission', 'Levels'] 
}