Bläddra i källkod

add json docs

ruki 4 år sedan
förälder
incheckning
4e9cbcee85

+ 61 - 0
manual/extension_modules.md

@@ -133,6 +133,67 @@ function main(...)
 end
 ```
 
+### core.base.json
+
+xmake provides a built-in json module, based on the implementation of lua_cjson, we can use it to quickly and directly interoperate between json and lua table.
+
+We can use `import("core.base.json")` to directly import and use.
+
+There are also some examples here: [Jsom Examples](https://github.com/xmake-io/xmake/blob/master/tests/modules/json/test.lua)
+
+#### json.decode
+
+Obtain the lua table directly from the string decoding json.
+
+```lua
+import("core.base.json")
+local luatable = json.decode('[1,"2", {"a":1, "b":true}]')
+print(luatable)
+```
+
+```
+{
+    1.0,
+    "2",
+    {
+      b = true,
+      a = 1.0
+    }
+  }
+```
+
+!> If there is null in it, you can use `json.null` to judge
+
+#### json.encode
+
+We can also directly encode a lua table.
+
+```lua
+local jsonstr = json.encode({1, "2", {a = 1}}
+```
+
+It should be noted that if you need to encode null, you need to use `json.null`, for example
+
+```lua
+local jsonstr = json.encode({json.null, 1, "2", false, true})
+```
+
+#### json.loadfile
+
+Load the json file directly and parse it into a lua table.
+
+```lua
+local luatable = json.loadfile("/tmp/xxx.json")
+```
+
+#### json.savefile
+
+Save the lua table to the specified json file.
+
+```lua
+json.savefile("/tmp/xxx.json", {1, {a = 1}})
+```
+
 ### core.tool.linker
 
 Linker related operations, often used for plugin development.

+ 34 - 0
mirror/manual/extension_modules.html

@@ -193,6 +193,40 @@ function main(...)
     task.run("config", {plat="iphoneos", arch="armv7"})
 end
 </code></pre>
+<h3 id="corebasejson">core.base.json</h3>
+<p>xmake provides a built-in json module, based on the implementation of lua_cjson, we can use it to quickly and directly interoperate between json and lua table.</p>
+<p>We can use <code>import("core.base.json")</code> to directly import and use.</p>
+<p>There are also some examples here: <a href="https://github.com/xmake-io/xmake/blob/master/tests/modules/json/test.lua">Jsom Examples</a></p>
+<h4 id="jsondecode">json.decode</h4>
+<p>Obtain the lua table directly from the string decoding json.</p>
+<pre><code class="lang-lua">import("core.base.json")
+local luatable = json.decode(&#39;[1,"2", {"a":1, "b":true}]&#39;)
+print(luatable)
+</code></pre>
+<pre><code>{
+    1.0,
+    "2",
+    {
+      b = true,
+      a = 1.0
+    }
+  }
+</code></pre><p>!> If there is null in it, you can use <code>json.null</code> to judge</p>
+<h4 id="jsonencode">json.encode</h4>
+<p>We can also directly encode a lua table.</p>
+<pre><code class="lang-lua">local jsonstr = json.encode({1, "2", {a = 1}}
+</code></pre>
+<p>It should be noted that if you need to encode null, you need to use <code>json.null</code>, for example</p>
+<pre><code class="lang-lua">local jsonstr = json.encode({json.null, 1, "2", false, true})
+</code></pre>
+<h4 id="jsonloadfile">json.loadfile</h4>
+<p>Load the json file directly and parse it into a lua table.</p>
+<pre><code class="lang-lua">local luatable = json.loadfile("/tmp/xxx.json")
+</code></pre>
+<h4 id="jsonsavefile">json.savefile</h4>
+<p>Save the lua table to the specified json file.</p>
+<pre><code class="lang-lua">json.savefile("/tmp/xxx.json", {1, {a = 1}})
+</code></pre>
 <h3 id="coretoollinker">core.tool.linker</h3>
 <p>Linker related operations, often used for plugin development.</p>
 <h4 id="linkerlink">linker.link</h4>

+ 34 - 0
mirror/zh-cn/manual/extension_modules.html

@@ -193,6 +193,40 @@ function main(...)
     task.run("config", {plat="iphoneos", arch="armv7"})
 emd
 </code></pre>
+<h3 id="corebasejson">core.base.json</h3>
+<p>xmake 提供了内置的 json 模块,基于 lua_cjson 实现,我们可以用它实现快速的在 json 和 lua table 直接相互操作。</p>
+<p>我们可以通过 <code>import("core.base.json")</code> 直接导入使用。</p>
+<p>这里也有一些例子:<a href="https://github.com/xmake-io/xmake/blob/master/tests/modules/json/test.lua">Jsom Examples</a></p>
+<h4 id="jsondecode">json.decode</h4>
+<p>直接从字符串解码 json 获取 lua table.</p>
+<pre><code class="lang-lua">import("core.base.json")
+local luatable = json.decode(&#39;[1,"2", {"a":1, "b":true}]&#39;)
+print(luatable)
+</code></pre>
+<pre><code>{
+    1.0,
+    "2",
+    {
+      b = true,
+      a = 1.0
+    }
+  }
+</code></pre><p>!> 如果里面有 null,可以用 <code>json.null</code> 来判断</p>
+<h4 id="jsonencode">json.encode</h4>
+<p>我们也可以直接对一个 lua table 进行编码。</p>
+<pre><code class="lang-lua">local jsonstr = json.encode({1, "2", {a = 1}}
+</code></pre>
+<p>需要注意的是,如果需要编码 null,需要使用 <code>json.null</code>,例如</p>
+<pre><code class="lang-lua">local jsonstr = json.encode({json.null, 1, "2", false, true})
+</code></pre>
+<h4 id="jsonloadfile">json.loadfile</h4>
+<p>直接加载 json 文件,并解析成 lua table。</p>
+<pre><code class="lang-lua">local luatable = json.loadfile("/tmp/xxx.json")
+</code></pre>
+<h4 id="jsonsavefile">json.savefile</h4>
+<p>保存 lua table 到指定 json 文件。</p>
+<pre><code class="lang-lua">json.savefile("/tmp/xxx.json", {1, {a = 1}})
+</code></pre>
 <h3 id="coretoollinker">core.tool.linker</h3>
 <p>链接器相关操作,常用于插件开发。</p>
 <h4 id="linkerlink">linker.link</h4>

+ 90 - 90
sitemap.xml

@@ -12,452 +12,452 @@
 
 <url>
   <loc>https://xmake.io/mirror/guide/project_examples.html</loc>
-  <lastmod>2021-12-22T10:23:28+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/other_features.html</loc>
-  <lastmod>2021-12-22T10:23:28+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/quickstart.html</loc>
-  <lastmod>2021-12-22T10:23:28+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/faq.html</loc>
-  <lastmod>2021-12-22T10:23:28+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/configuration.html</loc>
-  <lastmod>2021-12-22T10:23:28+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:15+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/syntax_description.html</loc>
-  <lastmod>2021-12-22T10:23:29+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/guide/installation.html</loc>
-  <lastmod>2021-12-22T10:23:29+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/plugin_development.html</loc>
-  <lastmod>2021-12-22T10:23:29+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/more_plugins.html</loc>
-  <lastmod>2021-12-22T10:23:29+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/plugin/builtin_plugins.html</loc>
-  <lastmod>2021-12-22T10:23:29+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/awesome.html</loc>
-  <lastmod>2021-12-22T10:23:29+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/technical_support.html</loc>
-  <lastmod>2021-12-22T10:23:30+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:16+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/changelog.html</loc>
-  <lastmod>2021-12-22T10:23:30+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/contact.html</loc>
-  <lastmod>2021-12-22T10:23:30+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/introduction.html</loc>
-  <lastmod>2021-12-22T10:23:30+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/who_is_using_xmake.html</loc>
-  <lastmod>2021-12-22T10:23:30+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/about/sponsor.html</loc>
-  <lastmod>2021-12-22T10:23:30+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/project_examples.html</loc>
-  <lastmod>2021-12-22T10:23:31+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:17+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/other_features.html</loc>
-  <lastmod>2021-12-22T10:23:31+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/quickstart.html</loc>
-  <lastmod>2021-12-22T10:23:31+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/faq.html</loc>
-  <lastmod>2021-12-22T10:23:31+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/configuration.html</loc>
-  <lastmod>2021-12-22T10:23:31+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/syntax_description.html</loc>
-  <lastmod>2021-12-22T10:23:31+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/guide/installation.html</loc>
-  <lastmod>2021-12-22T10:23:32+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/plugin_development.html</loc>
-  <lastmod>2021-12-22T10:23:32+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:18+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/more_plugins.html</loc>
-  <lastmod>2021-12-22T10:23:32+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/plugin/builtin_plugins.html</loc>
-  <lastmod>2021-12-22T10:23:32+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/awesome.html</loc>
-  <lastmod>2021-12-22T10:23:32+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/technical_support.html</loc>
-  <lastmod>2021-12-22T10:23:32+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/changelog.html</loc>
-  <lastmod>2021-12-22T10:23:32+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/contact.html</loc>
-  <lastmod>2021-12-22T10:23:33+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:19+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/peripheral_items.html</loc>
-  <lastmod>2021-12-22T10:23:33+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/introduction.html</loc>
-  <lastmod>2021-12-22T10:23:33+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/who_is_using_xmake.html</loc>
-  <lastmod>2021-12-22T10:23:33+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/sponsor.html</loc>
-  <lastmod>2021-12-22T10:23:33+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/about/course.html</loc>
-  <lastmod>2021-12-22T10:23:33+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/getting_started.html</loc>
-  <lastmod>2021-12-22T10:23:34+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/specification.html</loc>
-  <lastmod>2021-12-22T10:23:34+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:20+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_variables.html</loc>
-  <lastmod>2021-12-22T10:23:34+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/conditions.html</loc>
-  <lastmod>2021-12-22T10:23:34+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_rule.html</loc>
-  <lastmod>2021-12-22T10:23:34+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/target_instance.html</loc>
-  <lastmod>2021-12-22T10:23:34+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/project_target.html</loc>
-  <lastmod>2021-12-22T10:23:35+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/builtin_modules.html</loc>
-  <lastmod>2021-12-22T10:23:35+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:21+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/custom_toolchain.html</loc>
-  <lastmod>2021-12-22T10:23:35+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/plugin_task.html</loc>
-  <lastmod>2021-12-22T10:23:35+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_dependencies.html</loc>
-  <lastmod>2021-12-22T10:23:35+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/configuration_option.html</loc>
-  <lastmod>2021-12-22T10:23:35+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/extension_modules.html</loc>
-  <lastmod>2021-12-22T10:23:36+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/helper_interfaces.html</loc>
-  <lastmod>2021-12-22T10:23:36+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/global_interfaces.html</loc>
-  <lastmod>2021-12-22T10:23:36+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:22+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/package_instance.html</loc>
-  <lastmod>2021-12-22T10:23:36+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/manual/option_instance.html</loc>
-  <lastmod>2021-12-22T10:23:36+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/builtin_themes.html</loc>
-  <lastmod>2021-12-22T10:23:36+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/theme/switch_theme.html</loc>
-  <lastmod>2021-12-22T10:23:37+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/index.html</loc>
-  <lastmod>2021-12-22T10:23:37+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_3rd_source_library.html</loc>
-  <lastmod>2021-12-22T10:23:37+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:23+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package_old.html</loc>
-  <lastmod>2021-12-22T10:23:37+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/local_package.html</loc>
-  <lastmod>2021-12-22T10:23:37+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/system_package.html</loc>
-  <lastmod>2021-12-22T10:23:37+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/package/remote_package.html</loc>
-  <lastmod>2021-12-22T10:23:38+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/remote_toolchain.html</loc>
-  <lastmod>2021-12-22T10:23:38+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/zh-cn/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2021-12-22T10:23:38+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/getting_started.html</loc>
-  <lastmod>2021-12-22T10:23:38+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:24+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/specification.html</loc>
-  <lastmod>2021-12-22T10:23:38+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_variables.html</loc>
-  <lastmod>2021-12-22T10:23:38+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/conditions.html</loc>
-  <lastmod>2021-12-22T10:23:38+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_rule.html</loc>
-  <lastmod>2021-12-22T10:23:39+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/target_instance.html</loc>
-  <lastmod>2021-12-22T10:23:39+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/project_target.html</loc>
-  <lastmod>2021-12-22T10:23:39+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:25+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/builtin_modules.html</loc>
-  <lastmod>2021-12-22T10:23:39+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:26+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/custom_toolchain.html</loc>
-  <lastmod>2021-12-22T10:23:39+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:26+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/plugin_task.html</loc>
-  <lastmod>2021-12-22T10:23:39+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:26+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_dependencies.html</loc>
-  <lastmod>2021-12-22T10:23:40+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:26+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/configuration_option.html</loc>
-  <lastmod>2021-12-22T10:23:40+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:26+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/extension_modules.html</loc>
-  <lastmod>2021-12-22T10:23:40+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:26+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/helper_interfaces.html</loc>
-  <lastmod>2021-12-22T10:23:40+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:27+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/global_interfaces.html</loc>
-  <lastmod>2021-12-22T10:23:40+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:27+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/package_instance.html</loc>
-  <lastmod>2021-12-22T10:23:40+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:27+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/manual/option_instance.html</loc>
-  <lastmod>2021-12-22T10:23:41+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:27+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/builtin_themes.html</loc>
-  <lastmod>2021-12-22T10:23:41+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:27+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/theme/switch_theme.html</loc>
-  <lastmod>2021-12-22T10:23:41+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:27+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/index.html</loc>
-  <lastmod>2021-12-22T10:23:41+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:27+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_3rd_source_library.html</loc>
-  <lastmod>2021-12-22T10:23:41+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:28+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package_old.html</loc>
-  <lastmod>2021-12-22T10:23:41+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:28+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/local_package.html</loc>
-  <lastmod>2021-12-22T10:23:41+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:28+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/system_package.html</loc>
-  <lastmod>2021-12-22T10:23:42+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:28+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/package/remote_package.html</loc>
-  <lastmod>2021-12-22T10:23:42+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:28+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/remote_toolchain.html</loc>
-  <lastmod>2021-12-22T10:23:42+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:28+08:00</lastmod>
 </url>
 
 <url>
   <loc>https://xmake.io/mirror/toolchain/builtin_toolchains.html</loc>
-  <lastmod>2021-12-22T10:23:42+08:00</lastmod>
+  <lastmod>2021-12-23T09:07:29+08:00</lastmod>
 </url>
 
 </urlset>

+ 61 - 0
zh-cn/manual/extension_modules.md

@@ -133,6 +133,67 @@ function main(...)
 emd
 ```
 
+### core.base.json
+
+xmake 提供了内置的 json 模块,基于 lua_cjson 实现,我们可以用它实现快速的在 json 和 lua table 直接相互操作。
+
+我们可以通过 `import("core.base.json")` 直接导入使用。
+
+这里也有一些例子:[Jsom Examples](https://github.com/xmake-io/xmake/blob/master/tests/modules/json/test.lua)
+
+#### json.decode
+
+直接从字符串解码 json 获取 lua table.
+
+```lua
+import("core.base.json")
+local luatable = json.decode('[1,"2", {"a":1, "b":true}]')
+print(luatable)
+```
+
+```
+{
+    1.0,
+    "2",
+    {
+      b = true,
+      a = 1.0
+    }
+  }
+```
+
+!> 如果里面有 null,可以用 `json.null` 来判断
+
+#### json.encode
+
+我们也可以直接对一个 lua table 进行编码。
+
+```lua
+local jsonstr = json.encode({1, "2", {a = 1}}
+```
+
+需要注意的是,如果需要编码 null,需要使用 `json.null`,例如
+
+```lua
+local jsonstr = json.encode({json.null, 1, "2", false, true})
+```
+
+#### json.loadfile
+
+直接加载 json 文件,并解析成 lua table。
+
+```lua
+local luatable = json.loadfile("/tmp/xxx.json")
+```
+
+#### json.savefile
+
+保存 lua table 到指定 json 文件。
+
+```lua
+json.savefile("/tmp/xxx.json", {1, {a = 1}})
+```
+
 ### core.tool.linker
 
 链接器相关操作,常用于插件开发。