我正在使用JSON
值,如下所示
$.each(UMSGroupDetails, function (index, element) {
if (element.GroupName == UserGrouop.CT) {
umsGroupNameTo = element.GroupName;
umsGroupIdTo = element.GroupID;
}
});
和它的json数据一样
[{"GroupName":"CMM","GroupID":625},{"GroupName":"Construction_Eng","GroupID":626},{"GroupName":"DY. CTO","GroupID":624},{"GroupName":"Fiber Engineer","GroupID":622},{"GroupName":"Fiber Lead","GroupID":623}]
但是收到错误
'中的操作数无效:预期的对象
请说明这里有什么问题
更多信息
var LoginUserName = "Nadeem5.khan";
var UMSGroupDetailsObj = function () { return [{"GroupName":"CMM","GroupID":625},{"GroupName":"Construction_Eng","GroupID":626},{"GroupName":"DY. CTO","GroupID":624},{"GroupName":"Fiber Engineer","GroupID":622},{"GroupName":"Fiber Lead","GroupID":623}]; }
var UMSGroupDetails = JSON.stringify(UMSGroupDetailsObj());
var CurrentGroupName = "Fiber Engineer";
var CurrentGroupID = "622";
var UMSLocationDetailsObj = function () { return [{"LocationName":"Kalyan","LocationID":"INMUKLYN01"}]; }
var UMSLocationDetails = JSON.stringify(UMSLocationDetailsObj())
答案 0 :(得分:0)
不要做JSON.stringify(UMSGroupDetailsObj());因为你已经有了json格式
var LoginUserName = "Nadeem5.khan";
var UMSGroupDetailsObj = function () { return [{"GroupName":"CMM","GroupID":625},{"GroupName":"Construction_Eng","GroupID":626},{"GroupName":"DY. CTO","GroupID":624},{"GroupName":"Fiber Engineer","GroupID":622},{"GroupName":"Fiber Lead","GroupID":623}]; }
var UMSGroupDetails = UMSGroupDetailsObj;
var CurrentGroupName = "Fiber Engineer";
var CurrentGroupID = "622";
var UMSLocationDetailsObj = function () { return [{"LocationName":"Kalyan","LocationID":"INMUKLYN01"}]; }
var UMSLocationDetails = JSON.stringify(UMSLocationDetailsObj())
另外请检查json格式是否正确?