diff --git a/IPython/core/display.py b/IPython/core/display.py index 9bff6bf..1054abf 100644 --- a/IPython/core/display.py +++ b/IPython/core/display.py @@ -622,7 +622,7 @@ class JSON(DisplayObject): """ # wrap data in a property, which warns about passing already-serialized JSON _data = None - def __init__(self, data=None, url=None, filename=None, metadata=None, **kwargs): + def __init__(self, data=None, url=None, filename=None, expanded=False, metadata=None, **kwargs): """Create a JSON display object given raw data. Parameters @@ -640,9 +640,11 @@ class JSON(DisplayObject): metadata: dict Specify extra metadata to attach to the json display object. """ - self.metadata = kwargs + self.metadata = {'expanded': expanded} if metadata: self.metadata.update(metadata) + if kwargs: + self.metadata.update(kwargs) super(JSON, self).__init__(data=data, url=url, filename=filename) def _check_data(self): diff --git a/IPython/core/tests/test_display.py b/IPython/core/tests/test_display.py index fda5664..c639f92 100644 --- a/IPython/core/tests/test_display.py +++ b/IPython/core/tests/test_display.py @@ -159,7 +159,7 @@ def test_displayobject_repr(): def test_json(): d = {'a': 5} lis = [d] - md = {} + md = {'expanded': False} md2 = {'expanded': True} j = display.JSON(d) j2 = display.JSON(d, expanded=True)