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

Use n for total number of elements #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lunajson/decoder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ local function newdecoder()
end

if arraylen then -- commit the length of the array if `arraylen` is set
ary[0] = i
ary.n = i
end
rec_depth = rec_depth - 1
return ary
Expand Down
4 changes: 2 additions & 2 deletions src/lunajson/encoder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ end
local _ENV = nil


local function newencoder()
local function newencoder(saxtbl)
local v, nullv
local i, builder, visited

Expand Down Expand Up @@ -93,7 +93,7 @@ local function newencoder()
end
visited[o] = true

local tmp = o[0]
local tmp = o.n
if type(tmp) == 'number' then -- arraylen available
builder[i] = '['
i = i+1
Expand Down