文章目录
</div>
<h3 id="json字符串转为table"><a href="#json字符串转为table" class="headerlink" title="json字符串转为table"></a>json字符串转为table</h3><figure class="highlight plain"><table><tbody><tr><td class="code"><pre><div class="line">local cjson = require "cjson"</div><div class="line">local json = [[</div><div class="line"> {</div><div class="line"> "name": "御风小栈",</div><div class="line"> "url": "http://www.x86.pub"</div><div class="line"> }</div><div class="line">]]</div><div class="line">local table = cjson.decode(json)</div><div class="line">print(table["name"], table["url"])</div></pre></td></tr></tbody></table></figure>
table转为json字符串
local cjson = require "cjson" local table = {} table["name"] = "御风小栈" table["url"] = "http://www.x86.pub" local json = cjson.encode(table) print(json)
|
版权声明: 本博客所有文章除特别声明外,均采用 null 许可协议。转载请注明来自 安全书!