devtools.panels.ExtensionSidebarPane.setObject()

Displays a JSON object in the extension's sidebar pane.

The object is displayed as an expandable tree, as in the JSON viewer in Firefox. You can optionally specify a rootTitle string: this will be displayed as the title of the tree's root.

This is an asynchronous function that returns a Promise.

Syntax

js
let setting = browser.devtools.panels.setObject(
  jsonObject,       // string, array, or JSON object
  rootTitle         // string
)

Parameters

jsonObject

String or Array or Object. The object to display. If this is an object it is JSON-serialized, so properties like functions will be omitted.

rootTitle Optional

String. The title of the root of the tree in which the object is displayed.

Return value

A Promise that will be fulfilled with no arguments, once the object has been set.

Examples

Create a new pane, and populate it with a JSON object. You could run this code in a script loaded by your extension's devtools page.

js
function onCreated(sidebarPane) {
  sidebarPane.setObject({
    someBool: true,
    someString: "hello there",
    someObject: {
      someNumber: 42,
      someOtherString: "this is my pane's content",
    },
  });
}

browser.devtools.panels.elements.createSidebarPane("My pane").then(onCreated);

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
setObject
Chrome – Full support
Chrome 18 (Release date: 2012-03-28)
footnote
footnote If the jsonObject parameter is a string, it is not displayed.
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote
footnote If the jsonObject parameter is a string, it is not displayed.
Firefox – Full support
Firefox 57 (Release date: 2017-11-14)
footnote
footnote If the jsonObject is a string, then rootTitle must also be given, or jsonObject will not be displayed. See bug 1412310.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote
footnote If the jsonObject parameter is a string, it is not displayed.
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

Note: This API is based on Chromium's chrome.devtools.panels API.