1e85cfde13bbd201705061db53dce7ae4e16dbbf
[scilab.git] / scilab / modules / webtools / help / en_US / toJSON.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) 2017 - ESI-Group
5  *
6  * This file is hereby licensed under the terms of the GNU GPL v2.0,
7  * pursuant to article 5.3.4 of the CeCILL v.2.1.
8  * This file was originally licensed under the terms of the CeCILL v2.1,
9  * and continues to be available under such terms.
10  * For more information, see the COPYING file which you should have received
11  * along with this program.
12  *
13  -->
14
15 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
16           xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
17           xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
18           xml:lang="en" xml:id="toJSON">
19     <refnamediv>
20         <refname>toJSON</refname>
21         <refpurpose>
22             Convert scilab variable to JSON.
23         </refpurpose>
24     </refnamediv>
25     <refsynopsisdiv>
26         <title>Syntax</title>
27         <synopsis>
28             result = toJSON(var)
29             result = toJSON(var, filename)
30             result = toJSON(var, filename, indent)
31         </synopsis>
32     </refsynopsisdiv>
33     <refsection>
34         <title>Arguments</title>
35         <variablelist>
36             <varlistentry>
37                 <term>var</term>
38                 <listitem>
39                     <para>
40                         The Scilab variable to convert in JSON format.
41                     </para>
42                 </listitem>
43             </varlistentry>
44             <varlistentry>
45                 <term>filename</term>
46                 <listitem>
47                     <para>
48                         If a file name is given, the conversion is written in this file.
49                     </para>
50                 </listitem>
51             </varlistentry>
52             <varlistentry>
53                 <term>indent</term>
54                 <listitem>
55                     <para>
56                         If this argument is given, the result is indented. The value is the size of TAB.
57                     </para>
58                 </listitem>
59             </varlistentry>
60             <varlistentry>
61                 <term>result</term>
62                 <listitem>
63                     <para>
64                         Result is a string which contain the data converted to JSON.
65                         If a filename is given, no result is returned.
66                     </para>
67                 </listitem>
68             </varlistentry>
69         </variablelist>
70     </refsection>
71     <refsection>
72         <title>Description</title>
73         <para>
74             This function convert a Scilab variable into a string or JSON files.
75         </para>
76     </refsection>
77     <refsection>
78         <title>Examples</title>
79         <programlisting role="example"><![CDATA[
80 st = struct("status", "OK", "value", 12);
81 toJSON(st)
82 toJSON([1, 2, 3])
83 st = struct("test", ["a" "b"], "values", [1 2]);
84 toJSON(st, 4)
85  ]]></programlisting>
86     </refsection>
87     <refsection role="see also">
88         <title>See also</title>
89         <simplelist type="inline">
90             <member>
91                 <link linkend="http_post">http_post</link>
92             </member>
93             <member>
94                 <link linkend="http_put">http_put</link>
95             </member>
96             <member>
97                 <link linkend="http_patch">http_patch</link>
98             </member>
99             <member>
100                 <link linkend="http_delete">http_delete</link>
101             </member>
102             <member>
103                 <link linkend="http_upload">http_upload</link>
104             </member>
105             <member>
106                 <link linkend="fromJSON">fromJSON</link>
107             </member>
108             <member>
109                 <link linkend="http_get">http_get</link>
110             </member>
111         </simplelist>
112     </refsection>
113     <refsection>
114         <title>History</title>
115         <revhistory>
116             <revision>
117                 <revnumber>6.1</revnumber>
118                 <revremark>
119                     Function introduced.
120                 </revremark>
121             </revision>
122         </revhistory>
123     </refsection>
124 </refentry>