class_docstr: A view into a :class:`Sample` in a dataset.
  
  Like :class:`Sample` instances, the fields of a :class:`SampleView`
  instance can be modified, new fields can be created, and any changes can be
  saved to the database.
  
  :class:`SampleView` instances differ from :class:`Sample` instances in the
  following ways:
  
  -   A sample view may contain only a subset of the fields of its source
      sample, either by selecting and/or excluding specific fields
  -   A sample view may contain array fields or embedded array fields that
      have been filtered, thus containing only a subset of the array elements
      from the source sample
  -   Excluded fields of a sample view may not be accessed or modified
  
  .. note::
  
      Sample views should never be created manually; they are generated when
      accessing the samples in a :class:`fiftyone.core.view.DatasetView`.
  
  Args:
      doc: a :class:`fiftyone.core.odm.mixins.DatasetSampleDocument`
      view: the :class:`fiftyone.core.view.DatasetView` that the sample
          belongs to
      selected_fields (None): a set of field names that this sample view is
          restricted to, if any
      excluded_fields (None): a set of field names that are excluded from
          this sample view, if any
      filtered_fields (None): a set of field names of list fields that are
          filtered in this sample view, if any
class_docstr_tok: ["A","view","into","a",":","class",":","`","Sample","`","in","a","dataset",".","Like",":","class",":","`","Sample","`","instances",",","the","fields","of","a",":","class",":","`","SampleView","`","instance","can","be","modified",",","new","fields","can","be","created",",","and","any","changes","can","be","saved","to","the","database",".",":","class",":","`","SampleView","`","instances","differ","from",":","class",":","`","Sample","`","instances","in","the","following","ways",":","-","A","sample","view","may","contain","only","a","subset","of","the","fields","of","its","source","sample",",","either","by","selecting","and\/or","excluding","specific","fields","-","A","sample","view","may","contain","array","fields","or","embedded","array","fields","that","have","been","filtered",",","thus","containing","only","a","subset","of","the","array","elements","from","the","source","sample","-","Excluded","fields","of","a","sample","view","may","not","be","accessed","or","modified","..","note",":",":","Sample","views","should","never","be","created","manually",";","they","are","generated","when","accessing","the","samples","in","a",":","class",":","`","fiftyone.core.view.DatasetView","`",".","Args",":","doc",":","a",":","class",":","`","fiftyone.core.odm.mixins.DatasetSampleDocument","`","view",":","the",":","class",":","`","fiftyone.core.view.DatasetView","`","that","the","sample","belongs","to","selected_fields","(","None",")",":","a","set","of","field","names","that","this","sample","view","is","restricted","to",",","if","any","excluded_fields","(","None",")",":","a","set","of","field","names","that","are","excluded","from","this","sample","view",",","if","any","filtered_fields","(","None",")",":","a","set","of","field","names","of","list","fields","that","are","filtered","in","this","sample","view",",","if","any"]
docstr: Serializes the sample view to a JSON dictionary.
  
  Args:
      include_frames (False): whether to include the frame labels for
          video samples
      include_private (False): whether to include private fields
  
  Returns:
      a JSON dict
code: def to_dict(self, include_frames=False, include_private=False):
      """Serializes the sample view to a JSON dictionary.
  
      Args:
          include_frames (False): whether to include the frame labels for
              video samples
          include_private (False): whether to include private fields
  
      Returns:
          a JSON dict
      """
      d = super().to_dict(
          include_frames=include_frames, include_private=include_private
      )
  
      if self.selected_field_names or self.excluded_field_names:
          field_names = set(
              self._get_field_names(
                  include_private=include_private,
                  use_db_fields=True,
              )
          )
  
          if include_frames and self.media_type == fomm.VIDEO:
              field_names.add("frames")
  
          d = {k: v for k, v in d.items() if k in field_names}
  
      return d
  
imports: import os
  from bson import ObjectId
  from fiftyone.core.document import Document, DocumentView
  import fiftyone.core.frame
  import fiftyone.core.frame_utils
  import fiftyone.core.labels
  import fiftyone.core.metadata
  import fiftyone.core.media
  import fiftyone.core.odm
  import fiftyone.core.utils
  from fiftyone.core.singletons import SampleSingleton
label_desc: Use image node_id 3 for calling the SampleView obj's underlying member method code with example usage: obj.to_dict(include_frames, include_private) and returns: d