I got the following function written in python.
def get_campaign_id(campaigns, campaign_name):
for c in campaigns:
if c['name'] == campaign_name:
return c['id']
return None
campaigns is a list of dicts, e.g.
campaigns = [{'name': 'campaign1', 'id': 91203}]
and campaign_name is a str