* Bug #16408 fixed - toJSON(var, filename, indent) crashed Scilab.
[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, indent)
30             result = toJSON(var, filename)
31             result = toJSON(var, indent, filename)
32         </synopsis>
33     </refsynopsisdiv>
34     <refsection>
35         <title>Arguments</title>
36         <variablelist>
37             <varlistentry>
38                 <term>var</term>
39                 <listitem>
40                     <para>
41                         The Scilab variable to convert in JSON format.
42                     </para>
43                 </listitem>
44             </varlistentry>
45             <varlistentry>
46                 <term>filename</term>
47                 <listitem>
48                     <para>
49                         If a file name is given, the conversion is written in this file.
50                     </para>
51                 </listitem>
52             </varlistentry>
53             <varlistentry>
54                 <term>indent</term>
55                 <listitem>
56                     <para>
57                         If this argument is given, the result is indented. The value is the size of TAB.
58                     </para>
59                 </listitem>
60             </varlistentry>
61             <varlistentry>
62                 <term>result</term>
63                 <listitem>
64                     <para>
65                         Result is a string which contain the data converted to JSON.
66                         If a filename is given, no result is returned.
67                     </para>
68                 </listitem>
69             </varlistentry>
70         </variablelist>
71     </refsection>
72     <refsection>
73         <title>Description</title>
74         <para>
75             This function convert a Scilab variable into a string or JSON files.
76         </para>
77     </refsection>
78     <refsection>
79         <title>Examples</title>
80         <programlisting role="example"><![CDATA[
81 st = struct("status", "OK", "value", 12);
82 toJSON(st)
83 toJSON([1, 2, 3])
84 st = struct("test", ["a" "b"], "values", [1 2]);
85 toJSON(st, 4)
86  ]]></programlisting>
87     </refsection>
88     <refsection role="see also">
89         <title>See also</title>
90         <simplelist type="inline">
91             <member>
92                 <link linkend="http_post">http_post</link>
93             </member>
94             <member>
95                 <link linkend="http_put">http_put</link>
96             </member>
97             <member>
98                 <link linkend="http_patch">http_patch</link>
99             </member>
100             <member>
101                 <link linkend="http_delete">http_delete</link>
102             </member>
103             <member>
104                 <link linkend="http_upload">http_upload</link>
105             </member>
106             <member>
107                 <link linkend="fromJSON">fromJSON</link>
108             </member>
109             <member>
110                 <link linkend="http_get">http_get</link>
111             </member>
112         </simplelist>
113     </refsection>
114     <refsection>
115         <title>History</title>
116         <revhistory>
117             <revision>
118                 <revnumber>6.1</revnumber>
119                 <revremark>
120                     Function introduced.
121                 </revremark>
122             </revision>
123         </revhistory>
124     </refsection>
125 </refentry>