From HTTPService:JSONDecode(x), is there any way to get how many items exist

​From HTTPService:JSONDecode(x), is there any way to get how many items exist

A bit self explanatory but I have an API that will return something along the lines of:

{"orders":[{test="test",test1="test"}]}

I want to be able to check how many items exist in that list (in this case, test and test1 exist so I want it to return 1. What is the most efficient way to do this while keeping it simple.

Thank you, devforum gods.

function tableCount(tbl)
    local count = 0
    for i, v in pairs(tbl) do
        count += 1
    end
    return(count)
end

I wrote this on phone so might have typos and stuff.

2 Likes