Create a JSON display object given raw data. Parameters ---------- data : dict or list JSON data to display. Not an already-serialized JSON string. Scalar types (None, number, string) are not allowed, only dict or list containers.
(self, data=None, url=None, filename=None, expanded=False, metadata=None, root='root', **kwargs)
| 857 | # wrap data in a property, which warns about passing already-serialized JSON |
| 858 | _data = None |
| 859 | def __init__(self, data=None, url=None, filename=None, expanded=False, metadata=None, root='root', **kwargs): |
| 860 | """Create a JSON display object given raw data. |
| 861 | |
| 862 | Parameters |
| 863 | ---------- |
| 864 | data : dict or list |
| 865 | JSON data to display. Not an already-serialized JSON string. |
| 866 | Scalar types (None, number, string) are not allowed, only dict |
| 867 | or list containers. |
| 868 | url : unicode |
| 869 | A URL to download the data from. |
| 870 | filename : unicode |
| 871 | Path to a local file to load the data from. |
| 872 | expanded : boolean |
| 873 | Metadata to control whether a JSON display component is expanded. |
| 874 | metadata: dict |
| 875 | Specify extra metadata to attach to the json display object. |
| 876 | root : str |
| 877 | The name of the root element of the JSON tree |
| 878 | """ |
| 879 | self.metadata = { |
| 880 | 'expanded': expanded, |
| 881 | 'root': root, |
| 882 | } |
| 883 | if metadata: |
| 884 | self.metadata.update(metadata) |
| 885 | if kwargs: |
| 886 | self.metadata.update(kwargs) |
| 887 | super(JSON, self).__init__(data=data, url=url, filename=filename) |
| 888 | |
| 889 | def _check_data(self): |
| 890 | if self.data is not None and not isinstance(self.data, (dict, list)): |