【发布时间】:2019-03-16 15:21:12
【问题描述】:
所以,我必须使用 Lua 从 Openweathermap API 获取天气数据。 我设法发送了一个 http 请求来返回和存储所有数据,但现在我遇到了一个我不知道如何使用的 Lua 表。我对 Lua 很陌生,我没有找到任何关于 Lua 中如此深的嵌套表的指南或类似内容。
特别是我只对 main 中称为 temp 的字段感兴趣。以下是来自 API 的示例响应:Sample request response
依赖是 Lua 的 socket.http 和 this json 到 Lua 表格式化程序。 这是我的基本代码结构
json = require ("json")
web = require ("socket.http")
local get = json.decode(web.request(<API Link>))
“get”现在存储一个我不知道如何使用的表
【问题讨论】:
标签: json lua decode lua-table opencomputers