I am hitting an api endpoint using python requests to get some data and here is my template of my response.text(Actual response contains millions of event objects)
{"event":"Session","properties":{"time":"1642145186", "distinct_id":"ABC-123", "Region":"EU"}}
{"event":"Login","properties":{"time":"1642125126", "distinct_id":"ABC-123", "Region":"EU"}}
{"event":"Register","properties":{"time":"16432125126", "distinct_id":"ABC-123", "Region":"EU"}}
When I try to convert my response.text to json object using response.json()
or json.loads(json.dumps(response.text))
it throws the following error
json.decoder.JSONDecodeError: Extra data:
I do understand why it is throwing that error as the response.text is not in the right format what JSON object need to be and I would like to convert that text into a json object. Is it something we can do with regex so we can add a comma
at the end of each line(I am newbie with Regex concept)? Or any other option? I would really appreciate some help here.