Reattempt RapidJSON merge.

Ported Ken's lua code to C, fixed some bugs.
Does this really need to be in the tree?