Sapui5 如何遍历JSON模型?

Sapui5 如何遍历JSON模型?,sapui5,Sapui5,图像 Controller.js 项目:功能(evt){ var list=sap.ui.getCore().byId('appListId'); var sItem=list.getSelectedItem(); var oBindingContext=sItem.getBindingContext(“产品”); var sPath=oBindingContext.sPath; console.log(sPath);//获取路径/collection/0/App/0 var context=

图像

Controller.js

项目:功能(evt){
var list=sap.ui.getCore().byId('appListId');
var sItem=list.getSelectedItem();
var oBindingContext=sItem.getBindingContext(“产品”);
var sPath=oBindingContext.sPath;
console.log(sPath);//获取路径/collection/0/App/0
var context=sap.ui.getCore().byId(“appListId”).getModel(“产品”)
.getContext(sPath);
var start=sPath.lastIndexOf(“/”)+1;
var appIndex=sPath.substring(开始,sPath.length);
this.router.navTo(“selectedAppRecord”{
catIndex:this.subCatIndex,
appIndex:appIndex
});
}
JSON数组的路径:

获取此路径/集合/0/App/0
我有一个JSON数组:

{
“收藏”:[{
“模型”:“08报告欺诈”,
“应用程序”:[{
“应用程序”:“COUNCIL001”,
“说明”:“利益欺诈”,
“模块”:“08举报欺诈”,
“图标类”:“图标恶魔”,
“用户特定”:“是”
}]
}]
}

最后,我的目标是如何在控件端获取此特定于用户的键。

您可以使用BindingContext的
getProperty
函数来获取相关属性

var oItem=sap.ui.getCore().byId('appListId').getSelectedItem();
oItem.getBindingContext('products').getProperty('UserSpecific');

在处理程序函数中,我建议从事件中获取当前项:

oEvent.getSource()|| oEvent.getSource().getSelectedItem()

取决于事件的类型(ListItem#select或List#selectionChange)。

不清楚您想要实现什么。您能添加一些详细信息来描述您的问题吗?@hirse我得到了上述函数的路径,并使用了UserSpecific的path want to键,该键是JSON格式的。