# Bug or intended behaviour in embed.json\_item()

**URL:** <https://discourse.bokeh.org/t/bug-or-intended-behaviour-in-embed-json-item/8265>\
**Category:** Community Support\
**Created:** [August 11, 2021, 11:48am UTC](https://discourse.bokeh.org/t/bug-or-intended-behaviour-in-embed-json-item/8265 "2021-08-11T11:48:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjw85](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/cjw85/32/3806_2.png) [@cjw85](https://discourse.bokeh.org/u/cjw85)\
**Post date:** [August 11, 2021, 11:48am UTC](https://discourse.bokeh.org/t/bug-or-intended-behaviour-in-embed-json-item/8265/1 "2021-08-11T11:48:39Z")

</div>

The docstring to the above function suggests it can be used to create json for embedding standalone Bokeh content. In my usecase I want to output the json representation of a plot (for an external service) but also use the plot immediately in my python application.

Using `embed.json_item(plot)`, followed by `layout(plot)` leads to errors that: `RuntimeError: Models must be owned by only a single document`. This can be avoided by using the APIs that `json_item()` uses internally in a slightly different manner. Namely if the `OutputDocumentFor` is used with the `always_new=True` option (which `json_item()` does not set).

I’m wondering if this is intended behaviour or an oversight and that perhaps `json_item()` should optionally expose the `always_new` option of `OutputDocumentFor`.

---

<div class="post-metadata">

**Author:** ![Bryan](https://discourse.bokeh.org/user_avatar/discourse.bokeh.org/bryan/32/3625_2.png) [@Bryan](https://discourse.bokeh.org/u/Bryan)\
**Post date:** [August 11, 2021, 11:32pm UTC](https://discourse.bokeh.org/t/bug-or-intended-behaviour-in-embed-json-item/8265/2 "2021-08-11T23:32:05Z")

</div>

Seems like a small bug / oversight. The use-case that was in mind for the development of `json_item` was e.g. embedding from a Flask endpoint. I don’t imagine the scenario you describe was ever considered. Please open a [GitHub Issue](https://github.com/bokeh/bokeh/issues).

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads.bokeh.org/original/2X/1/14eb24f9e10e4e9b78e3f10f66c04ffa96446e5a.svg) [@system](https://discourse.bokeh.org/u/system)\
**Post date:** [November 9, 2021, 11:32pm UTC](https://discourse.bokeh.org/t/bug-or-intended-behaviour-in-embed-json-item/8265/3 "2021-11-09T23:32:36Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
