openresty / lua-cjson

Lua CJSON is a fast JSON encoding/parsing module for Lua
http://www.kyne.com.au/~mark/software/lua-cjson.php
MIT License
433 stars 118 forks source link

attempt to call field 'decode_array_with_array_mt' (a nil value)? #33

Closed wuyachao closed 6 years ago

wuyachao commented 6 years ago

I look for all package.path.

/usr/local/lib/lua/5.1/cjson.so
/usr/local/Cellar/openresty/1.11.2.4/lualib/cjson.so

so mv /usr/local/lib/lua/5.1/cjson.so /usr/local/lib/lua/5.1/cjson.so.bak. then reload nginx.

when i use cjson.encode_empty_table_as_object(false) is ok. But the cjson.decode_array_with_array_mt(true) will cause error.

attempt to call field 'decode_array_with_array_mt' (a nil value)

env: mac openresty: openresty/1.11.2.4

agentzh commented 6 years ago

@wuyachao Seems like your openresty is just too old?

Try this:

brew untap homebrew/nginx   #  optional
brew tap openresty/brew
brew install openresty

The latest version is 1.13.6.1.

wuyachao commented 6 years ago

@agentzh I install the latest openresty/1.13.6.1. But it also cause this error. Build the master branch cjson. It can work.

so I guess it not included in the latest version?

agentzh commented 6 years ago

@wuyachao Oh, right, my bad. The latest features in lua-cjson is to be released in the next OpenResty version. The current latest OpenResty release does not have it yet. You need to use the git repo version of lua-cjson yourself.

wuyachao commented 6 years ago

@agentzh 👌

manishahluwalia commented 6 years ago

Thanks for the software, it's great.

I'm running into this issue as well. When can we get a new version of OpenResty that includes this fix?

agentzh commented 6 years ago

@manishahluwalia The latest lua-cjson will get included in the latest OpenResty release. It's been on our roadmap.