Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size of array #27

Open
jungjinki opened this issue Apr 20, 2019 · 1 comment
Open

size of array #27

jungjinki opened this issue Apr 20, 2019 · 1 comment

Comments

@jungjinki
Copy link

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.

[email protected]

@tst2005
Copy link
Contributor

tst2005 commented Apr 23, 2019

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 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants