1

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

1 Answer 1

1

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"]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.