json.encode square brackets - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: json.encode square brackets (/showthread.php?tid=4630) |
json.encode square brackets - Krstfr2k - 08.03.2023 Hello! Is there a way to add square brackets in the result when using json.encode? I want the following: Code: local var_ = json.encode({ to look like this: Code: "RoomStatus":[0] when using log(var_) RE: json.encode square brackets - admin - 08.03.2023 Code: json.encode({ RE: json.encode square brackets - Krstfr2k - 08.03.2023 Thank you! As a response from an API call, i get the following table: Code: API 08.03.2023 15:01:36 Is there a way to convert the "userdata" to a string? Whenever I try to access it, I get the error message "attempt to index field 'Room' (a userdata value)". RE: json.encode square brackets - admin - 08.03.2023 You don't need to convert it, it just states the data is empty (NULL). Since there's no separate NULL type in Lua so a userdata entry (json.null) is used instead. |