JsonReader

class JsonReader

Unbound reader for JSON deserialization

Members defined in JsonReader (3 members)

is_bound

R

Whether there currently is a reader bound to this resource.

__init__

bind

Bind a serialized JSON string for reading.

Attributes

property is_bound: bool

Whether there currently is a reader bound to this resource.

Methods

__init__() None
bind(s: str) syside.JsonReader

Bind a serialized JSON string for reading.

Note that only one reader can be bound at a time, binding again will raise ValueError. Suggested usage is through a context manager:

with reader.bind(json_str) as json:
    model, report = deserializer.accept(json, syside.DESERIALIZE_STANDARD)

The reader will attempt to infer the root node as:

  1. The first Namespace (not subtype) without an owning relationship.

  2. The first Element that has no serialized owning related element or owning relationship, starting from the first element in the JSON array, and following owning elements up.

  3. The first element in the array otherwise.