Lua: Executing a string and storing the output of the command in a variable
问题 I've got a Lua script that receives a function call in a string. I need to execute that call and retrieve the output as a string in a variable so I can later send it somewhere. For example, I will receive the string "json.encode('{1:1, 2:3, 5:8}')" . I'd like to execute it and get a variable with the value ret = json.encode('{1:1, 2:3, 5:8}') . I've tried using loadstring in a bunch of different ways, including a way I found in the docs, but I can't get it to work as I want: > s = "json