Class: QgsJsonEditWidget

A widget for displaying JSON data in a code highlighted text or tree form.

Added in version 3.20.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsJsonEditWidget

Base classes

QWidget

QObject

QPaintDevice

class qgis.gui.QgsJsonEditWidget[source]

Bases: QWidget

__init__(parent: QWidget | None = None)

Constructor for QgsJsonEditWidget.

Parameters:

parent (Optional[QWidget] = None) – parent widget

class FormatJson(*values)

Bases: IntEnum

Format mode in the text view

  • Indented: JSON data formatted with regular indentation

  • Compact: JSON data formatted as a compact one line string

  • Disabled: JSON data is not formatted

Compact = 1
Disabled = 2
Indented = 0
class View(*values)

Bases: IntEnum

View mode, text or tree.

  • Text: JSON data displayed as text.

  • Tree: JSON data displayed as tree. Tree view is disabled for invalid JSON data.

Text = 0
Tree = 1
jsonEditor(self) QgsCodeEditorJson | None[source]

Returns a reference to the JSON code editor used in the widget.

Added in version 3.36.

Return type:

Optional[QgsCodeEditorJson]

jsonText(self) str[source]

Returns the JSON text.

Return type:

str

setControlsVisible(self, visible: bool)[source]

Set the visibility of controls to visible.

Parameters:

visible (bool)

setFormatJsonMode(self, formatJson: QgsJsonEditWidget.FormatJson)[source]

Set the formatJson mode.

See also

FormatJson

Parameters:

formatJson (QgsJsonEditWidget.FormatJson)

setJsonText(self, jsonText: str | None)[source]

Set the JSON text in the widget to jsonText.

Parameters:

jsonText (Optional[str])

setView(self, view: QgsJsonEditWidget.View)[source]

Set the view mode.

See also

View

Parameters:

view (QgsJsonEditWidget.View)