I imported json data into Google scripts with:
var doc = Utilities.jsonParse(txt);
I can access most objects like ...
var date = doc.data1.dateTime;
var playerName = doc.data1.playerName;
var playerId = doc.data1.playerID;
var teamNumber = doc.data2.personal.team;
The bunch of objects I need to access contains numbers as the names of the objects ...
doc.data2.personal.team.87397394.otherdata
doc.data2.personal.team.87397395.otherdata
doc.data2.personal.team.87397396.otherdata
doc.data2.personal.team.87397397.otherdata
... but when I try to read data using ...
var teamId = doc.data2.personal.team.87397394;
... I get an "Missing, before expression" error message.
I tried this ...
var teamId = doc.data2.personal.team[87397394];
... and get the command "teamId undefined" in the log.
I also related this with the same result ...
var teamId = doc.data2.personal.team[+'6803761'];
I can read the names as strings very easily using "For In", but I cannot get to the objects themselves. Every example I have found so far uses brackets, so I don't understand what to do next.
Thank! Brian
UPDATE
, . , var test "undefined"...
for(var propertyName in doc.data2.personal.team) {
Logger.log (propertyNames);
var test = doc.data2.personal.team[propertyName];
}
, ...
87397394
87397395
87397396
87397397
, Google. , - . test undefined...
function myFunction1() {
var txt = UrlFetchApp.fetch("http://www.hersheydigital.com/replays/replays_1.json").getContentText();
var doc = Utilities.jsonParse(txt);
for(var propertyName in doc.datablock_battle_result.vehicles) {
Logger.log (propertyName);
var test = doc.datablock_battle_result.vehicles[propertyName];
}
}