lunajson
lunajson copied to clipboard
size of array
I am trying to get the size of an array. with json {"main":{"type":"1","paper":"A4"},"s1st":{"column":[1000,5,5],"text2":"text2str"}} t= json.decode( string, pos, null, arrlen ) I could get "1000" by t.s1st.column[1] and I expected to get 3 by t.s1st.column[0]. but error raisesd.
How can I know the size of "column" array ? Thank you in advance.
With the Lua length operator ?
local rawjsondata = [[ {"main":{"type":"1","paper":"A4"},"s1st":{"column":[1000,5,5],"text2":"text2str"}} ]]
local t = require "lunajson".decode(rawjsondata)
print( #t.s1st.column )