You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
問題情境如下:
我利用 nodejs call api 後得到一個 json file,我需要拆解 json file 後再拼成一個新的 json,
問題在api回來給我的API其中有一個key & values 長得像這樣
"#text": “/dev/watson”
我在取”#text” values的值時以這樣的方法取:
console.log(secContents.es_result.ibmsc_field[myKey].#text);
都會得到以下error:
console.log(secContents.es_result.ibmsc_field[myKey].#text);
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
=================== 這是分隔線 ===================
[SOLUTION]
將code 從
console.log(secContents.es_result.ibmsc_field[myKey].#text);
改成
console.log(secContents.es_result.ibmsc_field[myKey]["#text"]);
The text was updated successfully, but these errors were encountered: