dom/interfaces/json/nsIJSON.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/interfaces/json/nsIJSON.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "domstubs.idl"
    1.10 +
    1.11 +interface nsIInputStream;
    1.12 +interface nsIOutputStream;
    1.13 +interface nsIScriptGlobalObject;
    1.14 +
    1.15 +[ptr] native JSValPtr(JS::Value);
    1.16 +[ptr] native JSContext(JSContext);
    1.17 +
    1.18 +%{C++
    1.19 +#include "js/TypeDecls.h"
    1.20 +%}
    1.21 +
    1.22 +/**
    1.23 + * Don't use this!  Use JSON.parse and JSON.stringify directly.
    1.24 + */
    1.25 +[scriptable, uuid(083aebb0-7790-43b2-ae81-9e404e626236)]
    1.26 +interface nsIJSON : nsISupports
    1.27 +{
    1.28 +  /**
    1.29 +   * New users should use JSON.stringify!
    1.30 +   * The encode() method is only present for backward compatibility.
    1.31 +   * encode() is not a conforming JSON stringify implementation!
    1.32 +   */
    1.33 +  [deprecated,implicit_jscontext,optional_argc]
    1.34 +  AString encode([optional] in jsval value);
    1.35 +
    1.36 +  /**
    1.37 +   * New users should use JSON.stringify.
    1.38 +   * You may also want to have a look at nsIConverterOutputStream.
    1.39 +   *
    1.40 +   * The encodeToStream() method is only present for backward compatibility.
    1.41 +   * encodeToStream() is not a conforming JSON stringify implementation!
    1.42 +   */
    1.43 +  [deprecated,implicit_jscontext,optional_argc]
    1.44 +  void encodeToStream(in nsIOutputStream stream,
    1.45 +                      in string charset,
    1.46 +                      in boolean writeBOM,
    1.47 +                      [optional] in jsval value);
    1.48 +
    1.49 +  /**
    1.50 +   * New users should use JSON.parse!
    1.51 +   * The decode() method is only present for backward compatibility.
    1.52 +   */
    1.53 +  [deprecated,implicit_jscontext]
    1.54 +  jsval decode(in AString str);
    1.55 +
    1.56 +  [implicit_jscontext]
    1.57 +  jsval decodeFromStream(in nsIInputStream stream,
    1.58 +                         in long contentLength);
    1.59 +
    1.60 +  [noscript] AString  encodeFromJSVal(in JSValPtr value, in JSContext cx);
    1.61 +
    1.62 +  // Make sure you GCroot the result of this function before using it.
    1.63 +  [noscript] jsval    decodeToJSVal(in AString str, in JSContext cx);
    1.64 +};

mercurial