From 6923258b16d8f131ca8525f9c2af0dfd0c0c3ccd Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@tarantool.org>
Date: Sun, 2 Jun 2013 13:05:51 +0400
Subject: [PATCH] Update lua.result and add user manual (box.cjson module).

---
 doc/user/stored-procedures.xml | 61 ++++++++++++++++++++++++++++++++++
 test/box/lua.result            |  1 +
 2 files changed, 62 insertions(+)

diff --git a/doc/user/stored-procedures.xml b/doc/user/stored-procedures.xml
index e261ce51f7..d3b8ceebd2 100644
--- a/doc/user/stored-procedures.xml
+++ b/doc/user/stored-procedures.xml
@@ -1155,6 +1155,67 @@ localhost> lua t:find(1, 'abc')
 </variablelist>
 </section>
 
+<section xml:id="sp-box-cjson">
+    <title>Package <code>box.cjson</code></title>
+
+<variablelist xml:id="box.cjson" xreflabel="box.cjson">
+    <para>
+        This package provides JSON manipulation routines.
+        It's based on the <link xlink:href="http://www.kyne.com.au/~mark/software/lua-cjson.php">
+        Lua-CJSON package by Mark Pulford</link>.
+
+        For a complete manual on Lua-CJSON please read <link xlink:href="http://www.kyne.com.au/~mark/software/lua-cjson-manual.html">the official documentation</link>.
+    </para>
+    <varlistentry>
+        <term><emphasis role="lua">box.cjson.encode(object)</emphasis></term>
+        <listitem>
+            <para>Convert a Lua object to a JSON string.</para>
+        </listitem>
+    </varlistentry>
+    <varlistentry>
+        <term><emphasis role="lua">box.cjson.decode(string)</emphasis></term>
+        <listitem>
+            <para>Convert a JSON string to a Lua object.</para>
+        </listitem>
+    </varlistentry>
+</variablelist>
+    <bridgehead renderas="sect4">Example</bridgehead>
+<programlisting>
+lua box.cjson.encode(123)
+---
+ - 123
+...
+lua box.cjson.encode({123})
+---
+ - [123]
+...
+lua box.cjson.encode({123, 234, 345})
+---
+ - [123,234,345]
+...
+lua box.cjson.encode({abc = 234, cde = 345})
+---
+ - {"cde":345,"abc":234}
+...
+lua box.cjson.encode({hello = { 'world' } })
+---
+ - {"hello":["world"]}
+...
+lua box.cjson.decode('123')
+---
+ - 123
+...
+lua box.cjson.decode('[123, "hello"]')[2]
+---
+ - hello
+...
+lua box.cjson.decode('{"hello": "world"}').hello
+---
+ - world
+...
+</programlisting>
+</section>
+
 <section xml:id="sp-box-space">
     <title>Package <code>box.space</code></title>
 <variablelist xml:id="box.space" xreflabel="box.space">
diff --git a/test/box/lua.result b/test/box/lua.result
index f3775446c2..11a2cb5864 100644
--- a/test/box/lua.result
+++ b/test/box/lua.result
@@ -16,6 +16,7 @@ lua local t = {} for n in pairs(box) do table.insert(t, '  - box.' .. tostring(n
   - box.bless_space
   - box.call_loadproc
   - box.cfg
+  - box.cjson
   - box.counter
   - box.delete
   - box.dostring
-- 
GitLab