TipJsonPath = "res/Json/Tip.json";
TipJsonArr: any;
LoadTipJson() {
Laya.loader.load(this.TipJsonPath, Laya.Handler.create(this, this.onLoaded), null, Laya.Loader.JSON);
}
private onLoaded() {
let json: JSON = Laya.loader.getRes(this.TipJsonPath);
var str: string = JSON.stringify(json);
this.TipJsonArr = JSON.parse(str);
for (let i = 0; i < this.TipJsonArr.length; i++) {
console.log("ID " + this.TipJsonArr[i]["ID"] + " " + this.TipJsonArr[i]["Type"]);
}
}
json数据内容:
[
{
"ID": 1,
"ProductType": "项目1",
"TypeStr": "准备",
"StepStr": "型号步骤1",
"Type": "Type1",
"Step": "ZBGZ",
"StepID": 1,
"IsShowPop": 0
},
{
"ID": 2,
"ProductType": "项目1",
"TypeStr": "准备",
"StepStr": "型号步骤2",
"Type": "Type2",
"Step": "ZBGZ",
"StepID": 2,
"IsShowPop": 1
}
]