def find_json(raw):
 ret = {}
 for ind in range(len(raw)):
  working = '\n'.join(raw.splitlines()[ind:])
  try:
   ret = json.loads(working, object_hook=decode_dict)
  except ValueError:
   continue
  if ret:
   return ret
 if (not ret):
  raise ValueError

def find_json ( raw ) : ret = { } for ind in range ( len ( raw ) ) : working = '\n' . join ( raw . splitlines ( ) [ ind : ] ) try : ret = json . loads ( working , object_hook = decode_dict ) except ValueError : continue if ret : return ret if ( not ret ) : raise ValueError
pass in a raw string and load the json when is starts .