class_docstr: Container for inference data storage using xarray.
  
  For a detailed introduction to ``InferenceData`` objects and their usage, see
  :ref:`xarray_for_arviz`. This page provides help and documentation
  on ``InferenceData`` methods and their low level implementation.
class_docstr_tok: ["Container","for","inference","data","storage","using","xarray",".","For","a","detailed","introduction","to","``","InferenceData","``","objects","and","their","usage",",","see",":","ref",":","`","xarray_for_arviz","`",".","This","page","provides","help","and","documentation","on","``","InferenceData","``","methods","and","their","low","level","implementation","."]
docstr: Write InferenceData to a json file.
  
  Parameters
  ----------
  filename : str
      Location to write to
  groups : list, optional
      Groups where the transformation is to be applied. Can either be group names
      or metagroup names.
  filter_groups: {None, "like", "regex"}, optional, default=None
      If `None` (default), interpret groups as the real group or metagroup names.
      If "like", interpret groups as substrings of the real group or metagroup names.
      If "regex", interpret groups as regular expressions on the real group or
      metagroup names. A la `pandas.filter`.
  kwargs : dict
      kwargs passed to json.dump()
  
  Returns
  -------
  str
      Location of json file
docstr_tok: ["Write","InferenceData","to","a","json","file",".","Parameters","--","--","--","--","--","filename",":","str","Location","to","write","to","groups",":","list",",","optional","Groups","where","the","transformation","is","to","be","applied",".","Can","either","be","group","names","or","metagroup","names",".","filter_groups",":","{","None",",","``","like","''",",","``","regex","''","}",",","optional",",","default=None","If","`","None","`","(","default",")",",","interpret","groups","as","the","real","group","or","metagroup","names",".","If","``","like","''",",","interpret","groups","as","substrings","of","the","real","group","or","metagroup","names",".","If","``","regex","''",",","interpret","groups","as","regular","expressions","on","the","real","group","or","metagroup","names",".","A","la","`","pandas.filter","`",".","kwargs",":","dict","kwargs","passed","to","json.dump","(",")","Returns","--","--","--","-","str","Location","of","json","file"]
code: def to_json(
      self, filename, groups=None, filter_groups=None, **kwargs
  ):
      """Write InferenceData to a json file.
  
      Parameters
      ----------
      filename : str
          Location to write to
      groups : list, optional
          Groups where the transformation is to be applied. Can either be group names
          or metagroup names.
      filter_groups: {None, "like", "regex"}, optional, default=None
          If `None` (default), interpret groups as the real group or metagroup names.
          If "like", interpret groups as substrings of the real group or metagroup names.
          If "regex", interpret groups as regular expressions on the real group or
          metagroup names. A la `pandas.filter`.
      kwargs : dict
          kwargs passed to json.dump()
  
      Returns
      -------
      str
          Location of json file
      """
      idata_dict = _make_json_serializable(
          self.to_dict(groups=groups, filter_groups=filter_groups)
      )
  
      with open(filename, "w", encoding="utf8") as file:
          json.dump(idata_dict, file, **kwargs)
  
      return filename
  
imports: import os
  import re
  import sys
  import uuid
  import warnings
  from collections import OrderedDict, defaultdict
  from collections.abc import MutableMapping, Sequence
  from copy import copy
  from copy import deepcopy
  from datetime import datetime
  from html import escape
  from typing import TYPE_CHECKING, Any, Iterable, Iterator, List, Mapping, Optional, Tuple, TypeVar, Union, overload
  import numpy
  import xarray
  from packaging import version
  from ..rcparams import rcParams
  from ..utils import HtmlTemplate, _subset_list, _var_names, either_dict_or_kwargs
  from .base import _extend_xr_method, _make_json_serializable, dict_to_dataset
label_desc: Use image node_id 21 for calling the InferenceData obj's underlying member method code with example usage: obj.to_json(filename, groups, filter_groups) and returns: filename