I'm trying to figure out what I'm doing wrong here. I'm trying to quickly deserialize HTTP JSON output into a string to search thru and pull specific keys to see if they meet a certain condition. My code doesn't come back with any errors, but when I go to execute it, I receive the following notice:
Execute Anonymous Error Line: 15, Column: 1 System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set
My Apex code is as follows:
public static List<String> listGroups(){
HTTPRequest request = new HttpRequest();
request.setMethod('GET');
request.setHeader('Accept', 'application/json');
request.setEndpoint('callout:Website1/');
HTTPResponse response = new Http().send(request);
String http_response = response.getBody();
List<String> data = (List<String>) JSON.deserialize(http_response, List<String>.class);
return data;
}
And here is the function call I'm performing elsewhere in my Apex program:
List<String> output=listGroups();
JSON output example:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')/drive/root/children",
"value": [
{
"createdDateTime": "2018-06-04T20:30:42Z",
"eTag": "\"{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx},1\"",
"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"lastModifiedDateTime": "2018-06-04T20:30:42Z",
"name": "Jack's files",
"webUrl": "https://example.com/sites/xxxxx/",
"cTag": "\"c:{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx},0\"",
"size": 6566266651,
"createdBy": {
"user": {
"email": "[email protected]",
"id": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
"displayName": "Mike Bravo"
}
},
"lastModifiedBy": {
"user": {
"email": "[email protected]",
"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxx",
"displayName": "Mike Bravo"
}
},
"parentReference": {
"driveId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"driveType": "documentLibrary",
"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"path": "/drive/root:"
},
"fileSystemInfo": {
"createdDateTime": "2018-06-04T20:30:42Z",
"lastModifiedDateTime": "2018-06-04T20:30:42Z"
},
"folder": {
"childCount": 1
}
},
....}]
}
{ "response": [ ... content ...] }
)