Skip to content

Commit

Permalink
Added argument type-checking to json.decode()
Browse files Browse the repository at this point in the history
  • Loading branch information
rxi committed Sep 6, 2015
1 parent 89b0e90 commit bf3ebf6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions json.lua
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ end


function json.decode(str)
if type(str) ~= "string" then
error("expected argument of type string, got " .. type(str))
end
return ( parse(str, next_char(str, 1, space_chars, true)) )
end

Expand Down

0 comments on commit bf3ebf6

Please sign in to comment.