2016-08-05 5 views

Antwort

3

Try JSON.parse(...) auf der Quelle (da es buchstäblich JSON ist) und dann behandeln Sie es einfach wie ein Objekt Literal.

Da es ein Array ist, können Sie var array = JSON.parse(...) tun, dann erhalten Sie array[array.length - 1].objectID.

1

,

var lastObj = a[a.length - 1]; 

kehrt zurück, um das letzte Objekt in dem Array. Dann können Sie auf seine Eigenschaften zugreifen.

var objectID = lastObj['objectId']; 

Shortcut

var objectID = a[a.length - 1]['objectId']; 

Array.length kehren Gesamtelemente in dem Array, und weil Zahlen Null-basiert sind, wird den letzten Index 1 von der Länge nehmen. z.B. für ein Array mit 6 Elementen, ist der letzte Element-Index 5 (6-1) = 5)

Arbeitsschnipsel, I getrimmten Objekte bis zu 2.

var a = [{ 
 
     "type": "PAPER", 
 
     "data": null, 
 
     "proceedingNumber": "IPR2016-00546", 
 
     "petitionId": "1463786", 
 
     "mimeType": null, 
 
     "fileName": "'306 Petition.pdf", 
 
     "partyGroupType": "petitioner", 
 
     "proceedingPartyGroupId": null, 
 
     "availability": "PUBLIC", 
 
     "documentName": "Petition For Inter Partes Review U.S. Patent No. 8,772,306", 
 
     "pageCount": "0", 
 
     "documentType": "16", 
 
     "exhibitNumber": null, 
 
     "petitionVO": null, 
 
     "institutionDecisionVO": null, 
 
     "terminationDecisionVO": null, 
 
     "proceedingReqType": null, 
 
     "proceedingReqTypeId": null, 
 
     "proceedingReqTypeStatusId": null, 
 
     "appealId": null, 
 
     "internalUserProxyEmail": null, 
 
     "proceedingId": "1463786", 
 
     "paperType": "16", 
 
     "documentTypeId": 16, 
 
     "customMotionTypeName": null, 
 
     "otherMotionType": null, 
 
     "objectId": "d29ya3NwYWNlOi8vU3BhY2VzU3RvcmUvNGVjOGFjMzQtODI5Yi00OTZhLTg0ZDItMDU2NTQzNmQ4NTI0OzEuMA==", 
 
     "objectType": null, 
 
     "artifactSubmissionId": "84644821", 
 
     "exhibitSequenceNumber": null, 
 
     "dateAdded": "02/02/2016", 
 
     "uploadStatus": null, 
 
     "expungedFlag": "N", 
 
     "deletedFlag": null, 
 
     "docVersionLabel": null, 
 
     "filingDate": "02/02/2016", 
 
     "proceedingArtifactId": "169264898", 
 
     "artifactNumber": "1", 
 
     "petitionState": null, 
 
     "patentNumber": null, 
 
     "fileSize": 0, 
 
     "submitterId": 11915, 
 
     "comment": null, 
 
     "createdbyAuthorName": null, 
 
     "disableSelect": null, 
 
     "employeeId": null, 
 
     "lockControlNo": 0, 
 
     "paperTypeName": "Petition", 
 
     "proceedingPartyId": null, 
 
     "filingParty": "petitioner", 
 
     "documentCategory": null, 
 
     "showExpungeAction": false, 
 
     "showUnExpungeAction": false, 
 
     "showDownloadLink": true, 
 
     "skipUploadTaskRecord": false, 
 
     "showEditLink": true, 
 
     "inputStream": null 
 
    }, { 
 
     "type": "PAPER", 
 
     "data": null, 
 
     "proceedingNumber": "IPR2016-00546", 
 
     "petitionId": "1463786", 
 
     "mimeType": null, 
 
     "fileName": "306 Exhibit List.pdf", 
 
     "partyGroupType": "petitioner", 
 
     "proceedingPartyGroupId": null, 
 
     "availability": "PUBLIC", 
 
     "documentName": "Exhibit List", 
 
     "pageCount": "0", 
 
     "documentType": "16", 
 
     "exhibitNumber": null, 
 
     "petitionVO": null, 
 
     "institutionDecisionVO": null, 
 
     "terminationDecisionVO": null, 
 
     "proceedingReqType": null, 
 
     "proceedingReqTypeId": null, 
 
     "proceedingReqTypeStatusId": null, 
 
     "appealId": null, 
 
     "internalUserProxyEmail": null, 
 
     "proceedingId": "1463786", 
 
     "paperType": "16", 
 
     "documentTypeId": 16, 
 
     "customMotionTypeName": null, 
 
     "otherMotionType": null, 
 
     "objectId": "d29ya3NwYWNlOi8vU3BhY2VzU3RvcmUvNDBhMjRjMmQtYWZkZi00OTdlLThkN2ItZGQ2ZTE5MmVjMWVkOzEuMA==", 
 
     "objectType": null, 
 
     "artifactSubmissionId": "84644822", 
 
     "exhibitSequenceNumber": null, 
 
     "dateAdded": "02/02/2016", 
 
     "uploadStatus": null, 
 
     "expungedFlag": "N", 
 
     "deletedFlag": null, 
 
     "docVersionLabel": null, 
 
     "filingDate": "02/02/2016", 
 
     "proceedingArtifactId": "169264900", 
 
     "artifactNumber": "2", 
 
     "petitionState": null, 
 
     "patentNumber": null, 
 
     "fileSize": 0, 
 
     "submitterId": 11915, 
 
     "comment": null, 
 
     "createdbyAuthorName": null, 
 
     "disableSelect": null, 
 
     "employeeId": null, 
 
     "lockControlNo": 0, 
 
     "paperTypeName": "Petition", 
 
     "proceedingPartyId": null, 
 
     "filingParty": "petitioner", 
 
     "documentCategory": null, 
 
     "showExpungeAction": false, 
 
     "showUnExpungeAction": false, 
 
     "showDownloadLink": true, 
 
     "skipUploadTaskRecord": false, 
 
     "showEditLink": true, 
 
     "inputStream": null 
 
    }] 
 
console.log(a[a.length - 1]['objectId']);

+1

Diese Antwort benötigt Informationen zum Analysieren des JSON. Beachten Sie, dass das OP auf die JSON-Ausgabe verwiesen hat und erwähnt die Möglichkeit, RegEx zu verwenden, um auf die gewünschten Bits zuzugreifen. – JAAulde

+0

das funktionierte, aber ich musste es zuerst analysieren. –

Verwandte Themen