【发布时间】:2016-08-11 10:35:50
【问题描述】:
在 UI 中,我创建了一个对象并将其中一个属性设置为布尔值:
function UserObject(componentId, componentName, checkedOut) {
this.componentId = componentId;
this.componentName = componentName;
this.checkedOut = checkedOut; //this is boolean variable
}
但是从后端,当我在我的对象中设置布尔值时,json 将其转换为字符串。
private UserObject createUserObject(EntityDTO entity) {
UserObject userObject = new UserObject();
userObject.setComponentId(entity.getEntityId());
userObject.setComponentName(entity.getEntityName());
userObject.setCheckedOut(entity.getCheckedOut());
return userObject;
}
现在,问题来了,我匹配某些条件两次 (1),然后在从后端获取数据时创建 (2)。每当我匹配“checkedOut”对象的条件时,如果对象来自后端,它就会失败:
if(cell.value.checkedOut === true){
//some code
}else{
//some more code
}
我该怎么办?在此先感谢:)
【问题讨论】:
标签: javascript java angularjs json