code: def flatten_json(data, prefix = None):
      '''
      Flatten the data, optionally with each key prefixed.
      '''
      # iterate all items
      for item in data:
          # split the object
          flat, key, subs = split_obj(item, prefix)
  
          # just return fully flat objects
          if key is None:
              yield flat
              continue
  
          # otherwise recursively flatten the subobjects
          for sub in flatten_json(subs, key):
              sub.update(flat)
              yield suf flatten_json(data, prefix = None):
      '''
      Flatten the data, optionally with each key prefixed.
      '''
      # iterate all items
      for item in data:
          # split the object
          flat, key, subs = split_obj(item, prefix)
  
          # just return fully flat objects
          if key is None:
              yield flat
              continue
  
          # otherwise recursively flatten the subobjects
          for sub in flatten_json(subs, key):
              sub.update(flat)
              yield sub
docs: Flatten the data, optionally with each key prefixed.