I have a string of json data, though sometimes it is 'regular' json and sometimes the data is in json-lines format. Here is the current way I'm testing to see which format it is:
json_newlines = all([_line.strip()[-1].endswith((']', '}')) for _line in file_data.split('\n') if _line.strip()])
Is there a better way to do this, or does the above seem like a good way?