Showing posts with label luajson. Show all posts
Showing posts with label luajson. Show all posts

Friday, October 5, 2012

LuaJSON 1.3.1 Released

LuaJSON 1.3.1 released! If you use luarocks, just use luarocks install luajson since it should soon be in the repository.

This release's changes include:

  • Documented and tested compatibility with Lua 5.1, 5.2, and LuaJIT-2.0-beta10.
  • Documented and tested compatibility with the 'classic' strict module on Lua 5.1 and LuaJIT-2.0-beta10 as provided by the LuaJIT-2.0-beta10 package.
  • Tested after-the-fact compatibility with Penlight's 'pl.strict' module for all supported Lua versions.
  • Fixes supplied by François Perrad included to address problems found in 'strict' library handling.
  • Users of the direct 'json' module will have a polluted global environment with the 'json' module populated unconditionally.

If there are any other Lua environments that you would like added to my test matrix, please let me know. I am always open to suggestions and improvements. I host the project on github at https://github.com/harningt/luajson, so feel free to fork and submit merge-requests :)

A note on the 'json' module pollution: if there is a general consensus among users of the library (wherever they may be), I'll happily remove this pollution. I much prefer Lua 5.2's way of handling modules and don't mind the fact that creating a Lua module without the 'module' function has the side effect that Lua 5.1 doesn't even have the global pollution.

Thursday, December 29, 2011

LuaJSON 1.3 Released

LuaJSON 1.3 is released to the wild!
Major changes made:
  • new 'nothrow' global option - currently a trivial 'pcall' hook on decode, but could later resolve to a more efficient handler
  • enhanced error output from the 'next' branch
  • hopefully "stackless" parser - limit of parsing depth now as large as heap and not stack

Rockspec for those using LuaRocks if it hasn't hit their repo yet: https://raw.github.com/harningt/luajson/b7cb1e6221ae6b70b208b242c1654da39087230d/rockspecs/luajson-1.3-1.rockspec
GitHub link for signed tag: https://github.com/harningt/luajson/tree/1.3
Release download tarball: https://github.com/downloads/harningt/luajson/luajson-1.3.tar.gz

The "stackless" parser is basically a linearization of the LPeg parser so that it parses JSON tokens and passes them into a stack/state-machine implemented as a Lua state object. This degrades performance slightly in the pre 1.2.1 era, but removes C/LPeg stack depth problems encountered in all prior implementations (including the abominably slow 1.2.2 version that reduced the problem, but didn't solve it).

While profiling performance, I found that some unrolling versions seemed to be a wee bit faster, but used more memory and had more pagefaults. My focus on future releases of LuaJSON will be on speed, including a possibility of 2.0 release breaking compatibility in the interest of getting > 2 MB/s JSON parsing performance. Looking at the strict YAJL parser - it hits >100 MB/s on the same data where I get 2 MB/s at best. If I can pull in an MIT-like-licensed C-based JSON parser into Lua and get >= 10x performance, I may add an option for the parser to try to consume the other parser under the LuaJSON interface (for uniformity).

Later I plan on enhancing encoding performance, but for the time being, decoding is most important right now.

Thursday, January 20, 2011

LuaJSON Roadmap

My LuaJSON project (hosted at GitHub) has slowed down in development over time as new features are hard to implement when the problem is so well defined. I do have a few plans for LuaJSON, however.

First priorities:

  • Figure out how to do nil round-tripping safely
  • Create validation tests for the enhanced error output in the latest-and-greatest code
  • Make sure it works with Lua 5.2
Future items:
  • Prepare LuaJSON for inclusion in the Gentoo package database
  • Construct small C Lua extension to offer faster encoding options
  • Construct small C Lua extension to offer faster decoding options 
If there are any ideas for enhancements or new-found-bugs, please don't hesitate to post them on my LuaJSON issue-tracker or here.