I have written a script that grabs JSON from a website, parses it, then puts it on a sheet. The problem seems to come from one line of code:
dr.push(dataAll[obj].id);
dr.push(dataAll[obj].name);
dr.push(dataAll[obj].symbol);
dr.push(dataAll[obj].rank);
dr.push(dataAll[obj].price_usd);
dr.push(dataAll[obj].price_btc);
dr.push(dataAll[obj].available_supply);
dr.push(dataAll[obj].total_supply);
dr.push(dataAll[obj].percent_change_1h);
dr.push(dataAll[obj].percent_change_24h);
dr.push(dataAll[obj].percent_change_7d);
dr.push(dataAll[obj].last_updated);
dr.push(dataAll[obj].24h_volume_usd);
the "dr.push(dataAll[obj].24h_volume_usd);" line is the issue. When I try to save I get the following error:
"Missing ; before statement. (line 35, file "CryptoDataFetcher V1")"
Also, the "24" after the dataAll[obj]. is green text, but I have no idea what this means
Google Apps Scripts is based off of javascript. A javascript object property name cannot start with a number when using dot notation, as described in the documentation:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors
You can either change the property name to be alphanumeric but not start with a number, or use bracket notation:
dr.push(dataAll[obj]["24h_volume_usd"]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.