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)
| 588 | # wrap data in a property, which warns about passing already-serialized JSON |
| 589 | _data = None |
| 590 | def __init__(self, data=None, url=None, filename=None, expanded=False, metadata=None, root='root', **kwargs): |
| 591 | """Create a JSON display object given raw data. |
| 592 | |
| 593 | Parameters |
| 594 | ---------- |
| 595 | data : dict or list |
| 596 | JSON data to display. Not an already-serialized JSON string. |
| 597 | Scalar types (None, number, string) are not allowed, only dict |
| 598 | or list containers. |
| 599 | url : unicode |
| 600 | A URL to download the data from. |
| 601 | filename : unicode |
| 602 | Path to a local file to load the data from. |
| 603 | expanded : boolean |
| 604 | Metadata to control whether a JSON display component is expanded. |
| 605 | metadata : dict |
| 606 | Specify extra metadata to attach to the json display object. |
| 607 | root : str |
| 608 | The name of the root element of the JSON tree |
| 609 | """ |
| 610 | self.metadata = { |
| 611 | 'expanded': expanded, |
| 612 | 'root': root, |
| 613 | } |
| 614 | if metadata: |
| 615 | self.metadata.update(metadata) |
| 616 | if kwargs: |
| 617 | self.metadata.update(kwargs) |
| 618 | super(JSON, self).__init__(data=data, url=url, filename=filename) |
| 619 | |
| 620 | def _check_data(self): |
| 621 | if self.data is not None and not isinstance(self.data, (dict, list)): |