Kotlin / kotlin-jupyter

Kotlin kernel for Jupyter/IPython
Apache License 2.0
1.09k stars 106 forks source link

MIME encoded json gives unexpected result #387

Closed andrewhamon closed 1 year ago

andrewhamon commented 1 year ago

Baseline: JSON output in python

In a python notebook, I can do the following:

from IPython.display import JSON

JSON({'a': [1, 2, 3, 4,], 'b': {'inner1': 'helloworld', 'inner2': 'foobar'}})
image

Which gives a nice interactive, collapsable, searhable display.

Not working as expected: JSON output in kotlin

I tried achieving the same with Kotlin:

val jsonStr = """
{"a": [1, 2, 3, 4], "b": {"inner1": "helloworld", "inner2": "foobar"}}
"""

MIME("application/json" to jsonStr)
image

This is interpreted as JSON value of string, rather than a JSON object (however Jupyter seems to still think it is showing JSON - see the root label and the search box).

Is there a way to properly render a json value with MIME?

blshao84 commented 1 year ago

I have been looking for a solution for exactly the same problem ...