code: def load(fname, fixup=True, compressed=None, **kw):
      """Load JSON from a file, possibly fixing it up if initial load attempt fails
  
      Parameters
      ----------
      fixup : bool
        In case of failed load, apply a set of fixups with hope to resolve issues
        in JSON
      compressed : bool or None
        Flag whether to treat the file as XZ compressed. If None, this decision
        is made automatically based on the presence of a '.xz' extension in the
        filename
      **kw
        Passed into the load (and loads after fixups) function
      """
      with _suitable_open(fname, compressed)(fname, "rb") as f:
          try:
              jreader = codecs.getreader("utf-8")(f)
              return json.load(jreader, **kw)
          except json.JSONDecodeError as exc:
              if not fixup:
                  raise
              ce = CapturedException(exc)
              lgr.warning(
                  "Failed to decode content in %s: %s. Trying few tricks",
                  fname,
                  ce,
              )
  
              # Load entire content and replace common "abusers" which break JSON
              # comprehension but in general
              # are Ok
              with _suitable_open(fname)(fname, "rb") as f:
                  s_orig = s = codecs.getreader("utf-8")(f).read()
  
              for o, r in {
                  "\xa0": " ",  # non-breaking space
              }.items():
                  s = s.replace(o, r)
  
              if s == s_orig:
                  # we have done nothing, so just reraise previous exception
                  raise
              return loads(s, **kw)
  
file_path: datalad/datalad/support/json_py.py
imports: import io
  import codecs
  from os.path import dirname, exists, lexists
  from os import makedirs
  import os
  import os.path
  import json
  from datalad.support.exceptions import CapturedException
  from ..log import lgr
label_desc: Use image node_id 8 for calling a global function with example usage: load(fname, fixup, compressed) and returns: json, loads