michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "domstubs.idl" michael@0: michael@0: interface nsIInputStream; michael@0: interface nsIOutputStream; michael@0: interface nsIScriptGlobalObject; michael@0: michael@0: [ptr] native JSValPtr(JS::Value); michael@0: [ptr] native JSContext(JSContext); michael@0: michael@0: %{C++ michael@0: #include "js/TypeDecls.h" michael@0: %} michael@0: michael@0: /** michael@0: * Don't use this! Use JSON.parse and JSON.stringify directly. michael@0: */ michael@0: [scriptable, uuid(083aebb0-7790-43b2-ae81-9e404e626236)] michael@0: interface nsIJSON : nsISupports michael@0: { michael@0: /** michael@0: * New users should use JSON.stringify! michael@0: * The encode() method is only present for backward compatibility. michael@0: * encode() is not a conforming JSON stringify implementation! michael@0: */ michael@0: [deprecated,implicit_jscontext,optional_argc] michael@0: AString encode([optional] in jsval value); michael@0: michael@0: /** michael@0: * New users should use JSON.stringify. michael@0: * You may also want to have a look at nsIConverterOutputStream. michael@0: * michael@0: * The encodeToStream() method is only present for backward compatibility. michael@0: * encodeToStream() is not a conforming JSON stringify implementation! michael@0: */ michael@0: [deprecated,implicit_jscontext,optional_argc] michael@0: void encodeToStream(in nsIOutputStream stream, michael@0: in string charset, michael@0: in boolean writeBOM, michael@0: [optional] in jsval value); michael@0: michael@0: /** michael@0: * New users should use JSON.parse! michael@0: * The decode() method is only present for backward compatibility. michael@0: */ michael@0: [deprecated,implicit_jscontext] michael@0: jsval decode(in AString str); michael@0: michael@0: [implicit_jscontext] michael@0: jsval decodeFromStream(in nsIInputStream stream, michael@0: in long contentLength); michael@0: michael@0: [noscript] AString encodeFromJSVal(in JSValPtr value, in JSContext cx); michael@0: michael@0: // Make sure you GCroot the result of this function before using it. michael@0: [noscript] jsval decodeToJSVal(in AString str, in JSContext cx); michael@0: };