cirq.read_json

Read a JSON file that optionally contains cirq objects.

Used in the notebooks

Used in the tutorials

file_or_fn A filename (if a string or pathlib.Path) to read from, or an IO object (such as a file or buffer) to read from, or None to indicate that json_text argument should be used. Defaults to None.
json_text A string representation of the JSON to parse the object from, or else None indicating file_or_fn should be used. Defaults to None.
resolvers A list of functions that are called in order to turn the serialized cirq_type string into a constructable class. By default, top-level cirq objects that implement the SupportsJSON protocol are supported. You can extend the list of supported types by pre-pending custom resolvers. Each resolver should return None to indicate that it cannot resolve the given cirq_type and that the next resolver should be tried.

ValueError If either none of file_or_fn and json_text is specified, or both are specified.