File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 45
45
+ [ lua-resty-mysql 扩展] ( #Openresty_resty-mysql )
46
46
+ [ lua-resty-shell 扩展] ( http://www.cnblogs.com/tinywan/p/6809879.html )
47
47
+ [ lua-resty-template 扩展] ( https://github.com/Tinywan/lua_project_v0.01 )
48
+ + [ lua-resty-template 扩展] ( https://github.com/Tinywan/lua_project_v0.01 )
48
49
+ [ openresty扫描代码全局变量] ( #Openresty_all-var )
49
50
+ [ ngx Lua APi 方法和常量] ( #Openresty_http_status_constants )
50
51
+ ngx_lua 核心常量
368
369
id = 2
369
370
]]
370
371
` ` `
372
+ + json 和 lua table 转换
373
+ + [1] 将 json 转换成 lua table
374
+ ` ` ` lua
375
+ local json_str = ' {"is_male":"nan","name":"zhangsan","id":1}'
376
+ local t = json.decode(json_str)
377
+ ngx.say(format_table(t))
378
+ ` ` `
379
+ + [2] 将 lua table 转换成 json 字符串
380
+ ` ` ` lua
381
+ local t = [[{key= " table key" ,value= " table value" }]]
382
+ local json_str = json.encode(t)
383
+ ngx.say(json_str) -- " {key=\" table key\" ,value=\" table value\" }"
384
+ ` ` `
385
+ + [3] 将lua table转换成 json 数组 (lua 两个大括号表示一个数组)
386
+ ` ` ` lua
387
+ local t = {keys={" list1" ," list2" ," list3" },num=1}
388
+ local str = json.encode(t)
389
+ ngx.say(str) -- {" keys" :[" list1" ," list2" ," list3" ]," num" :1}
390
+ ` ` `
371
391
+ 编译执行与错误
372
392
+ error 错误
373
393
` ` ` lua
You can’t perform that action at this time.
0 commit comments