docstr: This was originally the serialize_report() function from xdist (ca03269).
  
  Returns the contents of this report as a dict of builtin entries, suitable for
  serialization.
  
  Experimental method.
docstr_tok: ["This","was","originally","the","serialize_report","(",")","function","from","xdist","(","ca03269",")",".","Returns","the","contents","of","this","report","as","a","dict","of","builtin","entries",",","suitable","for","serialization",".","Experimental","method","."]
code: def _to_json(self):
      """
      This was originally the serialize_report() function from xdist (ca03269).
  
      Returns the contents of this report as a dict of builtin entries, suitable for
      serialization.
  
      Experimental method.
      """
  
      def disassembled_report(rep):
          reprtraceback = rep.longrepr.reprtraceback.__dict__.copy()
          reprcrash = rep.longrepr.reprcrash.__dict__.copy()
  
          new_entries = []
          for entry in reprtraceback["reprentries"]:
              entry_data = {
                  "type": type(entry).__name__,
                  "data": entry.__dict__.copy(),
              }
              for key, value in entry_data["data"].items():
                  if hasattr(value, "__dict__"):
                      entry_data["data"][key] = value.__dict__.copy()
              new_entries.append(entry_data)
  
          reprtraceback["reprentries"] = new_entries
  
          return {
              "reprcrash": reprcrash,
              "reprtraceback": reprtraceback,
              "sections": rep.longrepr.sections,
          }
  
      d = self.__dict__.copy()
      if hasattr(self.longrepr, "toterminal"):
          if hasattr(self.longrepr, "reprtraceback") and hasattr(
              self.longrepr, "reprcrash"
          ):
              d["longrepr"] = disassembled_report(self)
          else:
              d["longrepr"] = six.text_type(self.longrepr)
      else:
          d["longrepr"] = self.longrepr
      for name in d:
          if isinstance(d[name], (py.path.local, Path)):
              d[name] = str(d[name])
          elif name == "result":
              d[name] = None  # for now
      return d
  
imports: from pprint import pprint
  import py
  import six
  from _pytest._code.code import ExceptionInfo
  from _pytest._code.code import ReprEntry
  from _pytest._code.code import ReprEntryNative
  from _pytest._code.code import ReprExceptionInfo
  from _pytest._code.code import ReprFileLocation
  from _pytest._code.code import ReprFuncArgs
  from _pytest._code.code import ReprLocals
  from _pytest._code.code import ReprTraceback
  from _pytest._code.code import TerminalRepr
  from _pytest.outcomes import skip
  from _pytest.pathlib import Path
label_desc: Use image node_id 12 for calling the BaseReport obj's underlying member method code with example usage: obj._to_json() and returns: d, dict