|
Yes, it's easy to do with the __call metamethod. An example: mt = { __call = function(self,x) return x end } t = {} setmetatable(t,mt) print(t(3))
Ah neat, thanks! I'll research and try it and come back if I have questions. :D
This might be quite involved, as I counted 45 JSON modules in LuaRocks alone. Just looking at three of them: (...)
Maybe I didn't explain myself well. The exported procedures already accept a per-request reader/writer that overrides the default reader/writer. I was thinking that maybe it's worth making the /default/ reader and writer an instance variable as well, instead of using lunajson. So I don't see why it would be significantly hard, and why the number of different libraries and interfaces matters. Of course the user must provide a reader/writer that satisfies a certain interface (e.g. the reader has to accept a string as input, and output whatever structure they want).
Thanks for taking a look! You mean in the function `String`? I think I put that comment before writing the function that converts a table to a query string; since that function already URI encodes the given values, there's no need for anything else.Only one thing came to mind: string.format("%q",s) will return some characters escaped (see the manual for more information).
siiky