0

I am trying to return the value of @microsoft.graph.downloadUrl from the json object below:

[
  {
    '@microsoft.graph.downloadUrl': 'https://public.bl.files.1drv.com/XXXX',
    createdDateTime: '2021-07-10T06:14:31.03Z',
    cTag: 'QQQQ',
    eTag: 'SSSS',
    id: 'FFFF',
    lastModifiedDateTime: '2021-07-12T09:27:21.69Z',
    name: 'FILE_NAME',
    size: 98580,
    webUrl: 'https://1drv.ms/b/SSSS',
    reactions: { commentCount: 0 },
    createdBy: { application: [Object], user: [Object] },
    lastModifiedBy: { user: [Object] },
    parentReference: {
      driveId: 'XXX',
      driveType: 'personal',
      id: 'YYYY!YYY',
      name: 'Documents',
      path: '/drive/root:/Documents'
    },
    file: { mimeType: 'application/pdf', hashes: [Object] },
    fileSystemInfo: {
      createdDateTime: '2021-07-10T06:14:31.03Z',
      lastModifiedDateTime: '2021-07-12T09:27:21.69Z'
    }
  }
]

I wish to use something like this that i had done to extract the name as I need to be able to get the @microsoft.graph.downloadUrl from each json object (known as f below) in 'files'.

var fileName = (JSON.stringify(files[f].name));

I tried both:

var fileURL = (JSON.stringify(files[f]."@microsoft.graph.downloadUrl"));
var fileURL = (JSON.stringify(files[f].@microsoft.graph.downloadUrl));

but neither work -- any help would be much appreciated!

tina
  • 35
  • 1
  • 6
  • 2
    you don't want to `JSON.stringify`, because then you're working with a STRING rather than an OBJECT - you'll probably want `files[f]["@microsoft.graph.downloadUrl"]` – Bravo Jul 12 '21 at 10:52
  • Does this answer your question? [How can I access a JavaScript object which has spaces in the object's key?](https://stackoverflow.com/questions/8317982/how-can-i-access-a-javascript-object-which-has-spaces-in-the-objects-key) – Sebastian Simon Jul 12 '21 at 11:10
  • @Bravo Thank you so much!! this definitely what i needed to do! im new to using javascript and json object so thank you so much! – tina Jul 12 '21 at 11:15

1 Answers1

1

You should just use files[f]["@microsoft.graph.downloadUrl"].

Andrey Popov
  • 7,362
  • 4
  • 38
  • 58