【发布时间】:2020-09-16 19:34:17
【问题描述】:
我有一个 JSON 字符串:
{
"entry_offset" : 180587225765,
"entry_size" : 54003,
"created_time" : 1577500878,
"additional_meta" : {
"geohash64" : 5637765837143565,
"mime_type" : "image/jpg"
}
我已经使用 Tarantool 的模块 json 将其转换为 Lua Table:
table = json.decode(JSONstring)
然后我想将表格插入到 ID = 1 的 Tarantool
box.space.somespace:insert{1, table}
当我选择以 JSON 形式添加到 Tarantool 数据库的表时,结果是这样的:
Cannot access values through key
我只能访问 table[1] 和 table[2]:table[1] 是 ID = 1 而 table[2] 是所有 JSON 字符串。这意味着我无法使用键访问 JSON 的值:table['entry_offset'], table['entry_size'], .... 当我尝试访问它们时返回 nil
那么如何将 Lua 表插入 Tarantool,然后通过其键访问值?
非常感谢您的帮助!!!
【问题讨论】:
标签: json lua lua-table tarantool