[英]Uncaught SyntaxError: Unexpected token : in JSON at position 362
我寫了一段JS代碼:
window.scraping = JSON.parse('"' + tab_url + '"' + ":" + JSON.stringify(scraping));
其中tab_url
是:
'"https://www.google.com/search?ei=UFd7XvKqG9DwaIauhLgB&q=integrate+discord+chat+in+atom&oq=integrate+discord+chat+in+atom&gs_l=psy-ab.3..0j0i22i30l3j0i22i10i30j0i22i30j0i22i10i30j0i22i30l3.205903.213924..214423...0.4..0.509.1961.0j1j0j1j2j1......0....1..gws-wiz.......0i71j0i67j0i131j0i131i67j0i10.DB2bC6vf4pE&ved=0ahUKEwjykr3I2LXoAhVQOBoKHQYXARcQ4dUDCAs&uact=5":{"title":"","text":"","ranking_word":{},"a":[],"img":[],"html":""}'
和scraping
在哪里:
var scraping = {
"title": "",
"text": "",
"ranking_word": {},
"a": [],
"img": [],
"html": ""
}
代碼返回一個錯誤:
Uncaught SyntaxError: Unexpected token : in JSON at position 362
我不明白為什么:
被拒絕...
我假設您想在 tab_url 中嵌入抓取對象。
嘗試運行此代碼段。
let scraping = { "title": "", "text": "", "ranking_word": {}, "a": [], "img": [], "html": "" }; let tab_url = `{"https://www.google.com/search?ei=UFd7XvKqG9DwaIauhLgB&q=integrate+discord+chat+in+atom&oq=integrate+discord+chat+in+atom&gs_l=psy-ab.3..0j0i22i30l3j0i22i10i30j0i22i30j0i22i10i30j0i22i30l3.205903.213924..214423...0.4..0.509.1961.0j1j0j1j2j1......0....1..gws-wiz.......0i71j0i67j0i131j0i131i67j0i10.DB2bC6vf4pE&ved=0ahUKEwjykr3I2LXoAhVQOBoKHQYXARcQ4dUDCAs&uact=5":${JSON.stringify(scraping)}}`; console.log(JSON.parse(tab_url));
.as-console-wrapper { max-height: 100% !important; top: 0; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.