我创建了一个包含一系列属性的记录对象(var record = {...})
console.log(记录)给我:
{ 'Label': 'Test Location 3',
'Doshii Location ID': '123',
'Zip API Key': 'LBUcHlihsel7JkiCuPykiRuQ1+upbiEZuRFYU/cI/VZ7e0u0ldSkJlcD/NvTUZJCkMznQ8Wk4/qPfzfyfopzQcATzkde3H/0EQbwfJ3qWY5GZj8aK2yUNPGP+rLZA3BeQOQhu4iJuZsVdno/prfG7419x78v5P1fwY8AMC6u6nSUW69bjD5dplMqdH7fQ+1gWlN0UIpMzJeY7TugELofk85DdQHxtu7/oeKiSdJ0Qs6Z/FprWEqcyUgKVHwsUBcGyIYzrGZx4Yt/GjanlhYhibPtmHyMQUseZ7x5TJodSlDxjHR8pSa6+MXLQ9xRs8Hn6COr7vVnIGMJtMkkNxmJ/g==',
'Zip Location ID': '123' }
console.log(JSON.stringify(record));
给我: {"Label":"Test Location 3","Doshii Location ID":"123","Zip API Key":"LBUcHlihsel7JkiCuPykiRuQ1+upbiEZuRFYU/cI/VZ7e0u0ldSkJlcD/NvTUZJCkMznQ8Wk4/qPfzfyfopzQcATzkde3H/0EQbwfJ3qWY5GZj8aK2yUNPGP+rLZA3BeQOQhu4iJuZsVdno/prfG7419x78v5P1fwY8AMC6u6nSUW69bjD5dplMqdH7fQ+1gWlN0UIpMzJeY7TugELofk85DdQHxtu7/oeKiSdJ0Qs6Z/FprWEqcyUgKVHwsUBcGyIYzrGZx4Yt/GjanlhYhibPtmHyMQUseZ7x5TJodSlDxjHR8pSa6+MXLQ9xRs8Hn6COr7vVnIGMJtMkkNxmJ/g==","Zip Location ID":"123"}
var label = record["Label"]
;
var newLocationObj = {
doshiiLocationId: record["Doshii Location ID"],
label: label,
zipApiKey: record["Zip API Key"],
zipLocationId: record["Zip Location ID"],
ownerUserKey: req.body.ownerUserKey,
createdByUserKey: tokenResult.userKey,
createdDate: currentDate,
lastModifiedDate: currentDate
};
console.log("new location object - ",newLocationObj);
输出为:
新位置对象-{ doshiiLocationId: '123',
label: undefined,
zipApiKey: 'YlBEMw3YfX7uHiD8N8fjBI/Vq1IDVyjJhd1tN/gHrzIXLQ2iokJhfdx4Xuk8ovn4cFE6ftnxtDK/9WKKhEWtSVJgbBLBDhivLTe6k2y8S4e5x9QP2EQIIOM/psU+CL0ECO6S+UV859KOybI7MQZ4R+3wpTXeRn/k7uHX//Nnto/kqICTzh8ua4gkKRxdG2BnlvU0A54GzC+MTAWvRSAmjHMOupT3PrIEv/vMnpdVqFMNk8e0Ks+o6TOsYS/NEue5OKYRkPhZwhrgJj12Tz5Mphi8+XJcGSRw1X5unTmpG5q6FUF/ekv3Xig4KAvrOPJWImPSZqvIU0V4rG7Y9H+uNw==',
zipLocationId: '123',
ownerUserKey: 'a791154f-c978-4c4d-8721-d3ee4e910fdf',
createdByUserKey: 'a791154f-c978-4c4d-8721-d3ee4e910fdf',
createdDate: '2019-04-03T09:53:57.724Z',
lastModifiedDate: '2019-04-03T09:53:57.724Z' }
我一生都无法弄清楚为什么标签未定义...有什么想法吗?
答案 0 :(得分:1)
您的Label
键在\ufeff
(Zero Width No-Break Space, Byte Order Mark or BOM)之前包含以下字符。
因此,要使用的右键是\ufeffLabel
而不是Label
,它将返回undefined
:
const label = record['\ufeffLabel'];
答案 1 :(得分:0)