How to iterate through each element within a nested table?

Hi, I’m trying to work out how to grab the values of each individual entry in this table via a for loop, but nothing that I’ve tried has worked so far.

And then print the locationName values:
example1
example2
example3

Here’s an example table:

local exampleTable = {

"CallingPoints": [
    {
      "callingPoint": [
        {
          "locationName": "example1"
        },
        {
          "locationName": "example2"
        },
        {
          "locationName": "example3"
        },
    ],
]
}

Any help would be greatly appreciated :slightly_smiling_face:

local function deepLoop(t:any, callback:(i:any,v:any,t:any)->(), iterator:any?):()
	iterator = iterator or pairs
	for i, v in iterator(t) do
		if type(v) == "table" then
			callback(i, v, t)
			deepLoop(v, callback, iterator)
		else
			callback(i, v, t)
		end
	end
end
3 Likes