dom/interfaces/json/nsIJSON.idl

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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

mercurial