2.1.3.9. JsonWidget

Contains the basic UI model for a JSON tree node.

Background

Pyfx models a JSON as a tree and the leaf of the tree represents the values inside the JSON data. For example,

1[
2   {
3     "Name": "John",
4     "Age": 18
5     "Phones": [
6         "xxx-xxx-xxxx"
7     ]
8   }
9]

Both values (John and 18) are leaf nodes, while all the other parenthesis are non-leaf nodes.

UI Model

While rendering, each node in the tree represents one line in the TUI and are managed by a single urwid widget. In the above example, "Name": "John"* is rendered by one JSONWidget.

As a result, each node requires both the actual value to be rendered (e.g. “John”), the key that in its parent (e.g. “Name”) and a boolean flag to indicate whether to display the key.

Classes

JSONWidget(node, expandable, display_key)

Base UI model represents a JSON tree node.