I am using the below code to parse JSON data to CSV from rest API, but there are some nested objects which I need in different columns, I have tried using JSON normalize but couldn't get through. can anyone please advise?
import requests
import json, pandas as pd
import csv
import urllib
URL = "https://dsv.ihsmvals.com/holidays/v1.0/symbol/FX-GBP/startDate/20210101/endDate/20211231"
response = urllib.request.urlopen(URL)
print(response)
text = response.read()
json_data = json.loads(text)
print(json_data)
df = pd.read_json(URL)
bn = pd.DataFrame(df.events.values.tolist())
pd.json_normalize(bn).head()
bn.to_csv("output.csv")