code: def serialize_json(obj, pretty=None, indent=None, **kwargs):
      ''' Return a serialized JSON representation of objects, suitable to
      send to BokehJS.
      This function is typically used to serialize single python objects in
      the manner expected by BokehJS. In particular, many datetime values are
      automatically normalized to an expected format. Some Bokeh objects can
      also be passed, but note that Bokeh models are typically properly
      serialized in the context of an entire Bokeh document.
      The resulting JSON always has sorted keys. By default. the output is
      as compact as possible unless pretty output or indentation is requested.
      Args:
          obj (obj) : the object to serialize to JSON format
          pretty (bool, optional) :
              Whether to generate prettified output. If ``True``, spaces are
              added after added after separators, and indentation and newlines
              are applied. (default: False)
              Pretty output can also be enabled with the environment variable
              ``BOKEH_PRETTY``, which overrides this argument, if set.
          indent (int or None, optional) :
              Amount of indentation to use in generated JSON output. If ``None``
              then no indentation is used, unless pretty output is enabled,
              in which case two spaces are used. (default: None)
      Any additional keyword arguments are passed to ``json.dumps``, except for
      some that  are computed internally, and cannot be overridden:
      * allow_nan
      * indent
      * separators
      * sort_keys
      Examples:
          .. code-block:: python
              >>> data = dict(b=np.datetime64('2017-01-01'), a = np.arange(3))
              >>>print(serialize_json(data))
              {"a":[0,1,2],"b":1483228800000.0}
              >>> print(serialize_json(data, pretty=True))
              {
                "a": [
                  0,
                  1,
                  2
                ],
                "b": 1483228800000.0
              }
      '''
      for name in ['allow_nan', 'separators', 'sort_keys']:
          if name in kwargs:
              raise ValueError("The value of %r is computed internally, overriding is not permissable." % name)
      if pretty is None:
          pretty = settings.pretty(False)
      if pretty:
          separators=(",", ": ")
      else:
          separators=(",", ":")
      if pretty and indent is None:
          indent = 2
      return json.dumps(obj, cls=BokehJSONEncoder, allow_nan=False, indent=indent, separators=separators, sort_keys=True, **kwargs)