JSON and Data outputs

(Aaron T Smusz) #1

Can I use “-1” to get the “last” element in a JSON data set ?

I have a response that looks like the below and I want to get the last event.

Will -1 work or do I have to know how many events there are ?
{
“events”: [
{
“actingUserEmail”: "skaboy71@gmail.com",
“actingUserIpAddress”: “107.142.109.108”,
“date”: “2016-10-12T18:36:47-07:00”,
“description”: “Document created by Aaron Smusz”,
“participantEmail”: "skaboy71@gmail.com",
“type”: “CREATED”,
“versionId”: “3AAABLblqZhAWNKcwxRiR8bHtc0TvVeuACkYw3gCLrpfzIa5U8irQueXriGYb-7sC1ej-KmOra7LTP6Yc103BVcd-zY2MUB-V”
},
{
“actingUserEmail”: "skaboy71@gmail.com",
“date”: “2016-10-12T18:36:49-07:00”,
“description”: “Sent out for signature to Sam Spade”,
“participantEmail”: "echosmusz1@sonic.net",
“type”: “SIGNATURE_REQUESTED”
},
{
“actingUserEmail”: "echosmusz1@sonic.net",
“actingUserIpAddress”: “107.142.109.108”,
“date”: “2016-10-12T18:37:00-07:00”,
“description”: “Document viewed by Sam Spade”,
“participantEmail”: "echosmusz1@sonic.net",
“type”: “EMAIL_VIEWED”
},
{
“actingUserEmail”: "echosmusz1@sonic.net",
“actingUserIpAddress”: “107.142.109.108”,
“comment”: “esignVersion: 0.9.0.82688, User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Safari/602.1.50”,
“date”: “2016-10-12T18:37:12-07:00”,
“description”: “Document e-signed by Sam Spade”,
“participantEmail”: "echosmusz1@sonic.net",
“type”: “ESIGNED”,
“versionId”: “3AAABLblqZhAyEAwccdwggHxnWLDfyYlfqdAl12ehVUNrFvoseP2pI–yJQG6fMA4SM7AN9M9Pf-2bPt-hISyS5HroDpFVuwp”
}
],
}

(Kellsey Shaw) #2

Hi Aaron,

It’s not possible to do that but you can use the Code service to work with JSON which is far more flexible so you’d be able to get the number of items and then select the last one.