Retrieve field with reserved word name [SOLVED]

I have a json file that has a field with the name “index”.

{
	"document": [
		"details": {
			"selectedservices": [
				"index": "02",
				"servicecode": "TRCK",
				"servicename": "Trucking"
			]
		}
	]
}

How can I retrieve the field with the name “index” as index is a reserved word?
When I use the following code I always get 1 as a result back instead of “02”:

let truck_index = record.document.details.selectedservices[0].index;

Never mind. I am able to solve this by not using the shorthand syntax for the field and write it like:

let truck_index = record.document.details.selectedservices[0].fields.index;

1 Like