Using JavaScript, how do I extract the Date, To, From, Subject and Text fields from the Gmail API\'s return (see below)?
It\'s not in the usual name-value pair, at l
Surfing on the Internet I have found this class which describes a Generic GMail Message. You might use this to easily parse the JSON (by using any of the wide range of provided libraries).
you can use e.g. filter
function as follows:
var extractField = function(json, fieldName) {
return json.payload.headers.filter(function(header) {
return header.name === fieldName;
})[0];
};
var date = extractField(response, "Date");
var subject = extractField(response, "Subject");
Does this help?