As far as I can tell, we don't provide a library that achieves that however you have options:
- Either use the JSON() C++ binding which would allow you traverse the json object in lua.
- Include a 3rd-party json-parser lua library that decodes the json string into a lua table.
@REDACTEDUSER There are lots of good Lua based encoder/decoders available that you can easily include in your project. (Here is a good one: http://regex.info/blog/lua/json).
Just put the json.lua file in the same folder as the script that you are working on in your Lumberyard project, then load the json.lua file using the code sample from the above website.
Hi I would like to follow up on this older post. I am making an GET request to a web api which brings back a json that I must parse, hopefully from within my lua script. I have been unsuccessful with getting rapidjson to work they way I need, and ideally I could do the parsing from within lua anyway so I have tried using a couple of different 3rd party lua libraies but continue to get the following error :
module 'json' not found:Module "json.luac" has not been registered with the Asset Database.
Any ideas on what I need to bypass this error and use 3rd party lua libraries?
Good question! I’ll asking the scripting team and see what I can find :)
Props to @REDACTEDUSER
I saved this json lua script to dev/<my_project>/scripts/json.lua https://github.com/craigmj/json4lua/blob/master/json/json.lua
Since LY 1.24 uses Lua 5.1, I had to replace line #238 to use loadstring() instead of load()
Afterwards, I imported the json.lua util script into my own lua script via
local json = require "scripts/json"
The filepath had to use forward slash otherwise I was receiving the same errors about module 'json' not found:Module "json.luac" has not been registered with the Asset Database.
Example Lua File using JSON: ly115976_LuaScriptRequiringJSON.zip|attachment (456 Bytes)
Adding new answers, comments, and votes is disabled.
How to compile lua scriptsasked 6 years ago
Convert VTL object to JSON in API gatewayasked 8 months ago
UI Canvas Lua - Find Element By IDAccepted Answerasked 5 years ago
Lua DebuggingAccepted Answerasked 6 years ago
Converting JSON string to table/ojbect in Luaasked 5 years ago
Lua API Document and Lua EditorAccepted Answerasked 6 years ago
Lumberyard Lua TutorialsAccepted Answerasked a year ago
Glue crawler json parsingasked 2 months ago
Update lua scripts on "Play Game" in editorAccepted Answerasked 5 years ago
Lua Tutorial not working. Am i doing something wrong?Accepted Answerasked 6 years ago