API json.encode feature

There is json.decode - I think a built in json.encode would be useful and logical.

There are other already made ways to do it but I think if json.decode exists so should json.encode for turning a lua table into JSON as a part of core api.

http://regex.info/blog/lua/json
http://lua-users.org/wiki/JsonModules

6 Likes

A json.encode would be great, I was surprised there is only a decode

@Pkeod Thanks for the Gist, I’m using it in my project now and it seems to work well.

I’m using this one now

5 Likes

Thanks again @Pkeod. Switched to the Playfab one (and its also working).

is there a reason why json.encode() is not available in the official API? :cry:

Yes, a semi vague reason. Should an empty table encode to a JSON object {} or an array []?

This is my goto solution for json.encode: https://github.com/rxi/json.lua

2 Likes