Lightweight Lua <-> JSON encoder/decoder extracted from Prosody.
I've fixed a minor inconvenience when handling NaN and infinity. JSON not supporting these special IEE 754 values is a common problem and the original code, like many implementations, generates invalid JSON when encountering NaN or infinity.
This implementation generates strings instead which is slightly better than invalid JSON for my application.
Other applications might be just fine with whatever tostring(nan/infinity)
produces (note that the output is platform-dependent).
I didn't want a dependency on LPeg and this implementation seems to be quite mature as it has been used for years in Prosody.