Skip to content

moretyping.vis.ViewJSON

Annotations

class ViewJSON(metaclass=VisualiseMeta):
    def __init__(self, data: Optional[Any] = {}) -> None:
        ...

    @cached_property
    def string(self) -> str:
        ...

    def __str__(self) -> str:
        ...

    def __repr__(self) -> str:
        ...

Parameters

data: Optional[Any]
Any JSON-compatible object.

Return Value

Returns a ViewJSON instance.

Properties

string: str
A JSON-serialised verison of the data.

Methods

def __str__(self) -> str:
    ...
Equivilant to the string property
def __repr__(self) -> str:
    ...
Class name + stringified data.

Details

For any object, returns the JSON conversion of it.

Example usage

from moretyping.vis import ViewJSON

data = {
    "users": [
        {
            "name": "User123",
            "age": 24,
        }
    ]
}

view = ViewJSON(data)

print(view)
#{
#   "users": [
#       {
#           "name": "User123",
#           "age": 24
#       }
#   ]
#}