JSON and XML Output via lua-nginx-module

1,148 views
Skip to first unread message

Gordon Madarm

unread,
May 20, 2014, 6:43:59 AM5/20/14
to openre...@googlegroups.com
I'm creating an API which should output its data in both JSON and XML (depending on a user controlled parameter). I'm a bit confused as to when using normal lua libraries (e.g. http://regex.info/blog/lua/json and http://viremo.eludi.net/LuaXML/) negatively affect blocking. Is it safe to use these or is there a better way to format output in OpenResty?

thanks,
- G

Yichun Zhang (agentzh)

unread,
May 20, 2014, 5:29:55 PM5/20/14
to openresty-en
Hello!
OpenResty comes with the lua-cjson library by default:

http://www.kyne.com.au/~mark/software/lua-cjson.php

I don't know if there's a good Lua XML library out there. Just pick
one that best fits your needs. Or use LuaJIT FFI to call into those
XML C libraries (like libxml2) directly:

http://luajit.org/ext_ffi.html

CPU computation is always blocking anyway but it's usually neglectable
(because it can usually be controlled to be really fast, on the level
of microseconds).

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages