jeudi 2 avril 2015

Trying to use a JSON object as a argument (Python)

I've written some code that converts a JSON object to an iCalendar (.ics) object and now I am trying to test it. The problem is that I can't figure out how to create a generic JSON object to use as the parameter. Some of my attempts are as follows:



# 1
obj_json = u'sample json data in string form'
obj = json.loads(obj_json)

# 2
# I'm not sure about this very first line. My supervisor told me to put it in but he
# has a very heavy accent so I definitely could have heard him incorrectly.
input.json
with open('input.json') as f:
obj = json.loads(f.read())

Aucun commentaire:

Enregistrer un commentaire