dom/interfaces/json/nsIJSON.idl

changeset 2
7e26c7da4463
equal deleted inserted replaced
-1:000000000000 0:30a36f3dea2c
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #include "domstubs.idl"
7
8 interface nsIInputStream;
9 interface nsIOutputStream;
10 interface nsIScriptGlobalObject;
11
12 [ptr] native JSValPtr(JS::Value);
13 [ptr] native JSContext(JSContext);
14
15 %{C++
16 #include "js/TypeDecls.h"
17 %}
18
19 /**
20 * Don't use this! Use JSON.parse and JSON.stringify directly.
21 */
22 [scriptable, uuid(083aebb0-7790-43b2-ae81-9e404e626236)]
23 interface nsIJSON : nsISupports
24 {
25 /**
26 * New users should use JSON.stringify!
27 * The encode() method is only present for backward compatibility.
28 * encode() is not a conforming JSON stringify implementation!
29 */
30 [deprecated,implicit_jscontext,optional_argc]
31 AString encode([optional] in jsval value);
32
33 /**
34 * New users should use JSON.stringify.
35 * You may also want to have a look at nsIConverterOutputStream.
36 *
37 * The encodeToStream() method is only present for backward compatibility.
38 * encodeToStream() is not a conforming JSON stringify implementation!
39 */
40 [deprecated,implicit_jscontext,optional_argc]
41 void encodeToStream(in nsIOutputStream stream,
42 in string charset,
43 in boolean writeBOM,
44 [optional] in jsval value);
45
46 /**
47 * New users should use JSON.parse!
48 * The decode() method is only present for backward compatibility.
49 */
50 [deprecated,implicit_jscontext]
51 jsval decode(in AString str);
52
53 [implicit_jscontext]
54 jsval decodeFromStream(in nsIInputStream stream,
55 in long contentLength);
56
57 [noscript] AString encodeFromJSVal(in JSValPtr value, in JSContext cx);
58
59 // Make sure you GCroot the result of this function before using it.
60 [noscript] jsval decodeToJSVal(in AString str, in JSContext cx);
61 };

mercurial