Infimyst Infimyst - 1 year ago 76
Javascript Question

How to Ignore numbers in javascript and json string?

var jsonJSON = UrlFetchApp.fetch("");
var json = Utilities.jsonParse(jsonJSON.getContentText());

var max24 = json.NA.formatted.24max;

I'm sure my code is sloppy but, I'm getting "Missing ; before statement." from the bottom line. It goes away when I remove the '24', but the source itself has '24max'.

Is there a way to have javascript ignore the 24 after the period? Or are the top two lines of code wrong?


Answer Source

Instead of removing the numbers in front of the object names during parsing, you can also access the object's property like you would access an array element like so.


JavaScript variables must begin with a letter, $ or _. That is the reason why you are getting an error instead.