Example:
os.loadAPI("json") str = http.get("http://www.someserver.com/").readAll() obj = json.decode(str) value = obj.thisVariableWasInTheJSONAndThisIsCoolerThanUsingStringGmatchToFindEverything jsonstring = json.encode(obj) sendThisToWhateverNeedsIt(jsonstring) -- Also, it is very good for very readable config files. prettystring = json.encodePretty(obj) saveThisToAFile(prettystring)
And now introducing json.encodePretty(). Let's say you want the text to be pretty instead of small. json.encodePretty() will return formatted text instead of compact text. This is useful for things like config files where you want your users to be able to read the json easily.
Finally, json.decodeFromFile(). If you have some JSON in a file, this function will read it for you without you having to open the file and read it manually. Just do
local object = json.decodeFromFile("path/to/file")
pastebin get 4nRg9CHU json
Changelog: