Get value from Javascript JSON object by referencing specific property name -
I am using Google Apps Script (JavaScript) so that I can retrieve a user's details.
The code to get the user is:
var url = 'https://www.googleapis.com/admin/directory/v1/users/'email+++++++++++++++++ + PublicApiAccessKey 'key =?'; Var scope = "https://www.googleapis.com/auth/admin.directory.user.readonly"; Var fetchArgs = googleOAuth _ ("user", field); FetchArgs.method = "GET"; FetchArgs.muteHttpExceptions = true var userObject = UrlFetchApp.fetch (url, fetchArgs); The response is as follows: {"kind": "admin # directory # user", "id": string, "tag": etag , "Name": {"givenName": string, "freeman": string, "full name": string}, "asen": boolean, "delimited admin": boolean, "last lagoon time How do I get value of fullName Logger.log (Object.prototype.toString.call (userObject)) // Return [Object Going Object] Logger.log (userObject.name.fullName); // can not read the property "full name" from undefined Logger.log (userObject.fullName); // Undefined Logger.log (userObject.name); // Undefined Logger. Log (userObject ['fullName']); // undefined Logger.log (userObject ['name']); // undefined Logger.log (userObject ['name', 'fullName']); // undefined
var userObject = Users.get (/ * ... args ... * /);
... Whatever layer you are using to get feedback, and therefore the userObject
user is not an object, like a custom XHR object The documents you have linked are particularly Java and Python, not browser-side. (Definitely except for using a Java applet.)
Check that document, maybe you provide callback / lambda or call a method on that object ( getContent
to get an attractive response).
Comments
Post a Comment