Reattempt RapidJSON merge.

Ported Ken's lua code to C, fixed some bugs.
I'm going to move it to testcases eventually, might as well reuse the hash.