Table length not working

I have a table that contains the following:

Table1 = {1=[120999, 2014-12-14 22:06:44, 2014-12-14 22:26:44, item1, item2], 2=[120999, 2014-12-14 22:06:44, 2014-12-14 22:26:44, item1, item2]}

When I try and get length using #Table1 it comes back nil.

Any suggestions? Thanks

I don’t believe that’s valid syntax.  It’s more JSON like:

Table1 = {}

Table1[1] = {x, y, z}

Table1[2] = { a, b, c }

It’s actually a json response from a network request. I just passed the json reponse to Table1 which was declared as a table.

So the code is:

Table1={}

local function update(event)

Table1=json.decode(event.response)

print(#Table1)

end

Did I miss a step?

I would print out what “event.response” is.

You can also use one of the table printing techniques to print your table out and see what values you have there.

Rob

OK thanks Rob. I realized I had to insert the data in to a table using k/v pairs loop then get length. I knew that, I suppose it’s time for a break!

I don’t believe that’s valid syntax.  It’s more JSON like:

Table1 = {}

Table1[1] = {x, y, z}

Table1[2] = { a, b, c }

It’s actually a json response from a network request. I just passed the json reponse to Table1 which was declared as a table.

So the code is:

Table1={}

local function update(event)

Table1=json.decode(event.response)

print(#Table1)

end

Did I miss a step?

I would print out what “event.response” is.

You can also use one of the table printing techniques to print your table out and see what values you have there.

Rob

OK thanks Rob. I realized I had to insert the data in to a table using k/v pairs loop then get length. I knew that, I suppose it’s time for a break!