From e92ec2f916e46a863d8e90bf12e0fc68cff222ec Mon Sep 17 00:00:00 2001 From: Barbara Ericson Date: Tue, 26 Mar 2024 08:20:19 -0400 Subject: [PATCH] trying to fix reading from a file --- _sources/_static/person2.json | 24 ++++++++++++++++++++++++ _sources/web/writeCode.rst | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 _sources/_static/person2.json diff --git a/_sources/_static/person2.json b/_sources/_static/person2.json new file mode 100644 index 00000000..24350df4 --- /dev/null +++ b/_sources/_static/person2.json @@ -0,0 +1,24 @@ +{ + "firstName": "John", + "lastName": "Smith", + "isAlive": true, + "age": 27, + "address": { + "streetAddress": "21 2nd Street", + "city": "New York", + "state": "NY", + "postalCode": "10021-3100" + }, + "phoneNumbers": [ + { + "type": "home", + "number": "212 555-1234" + }, + { + "type": "mobile", + "number": "123 456-7890" + } + ], + "children": [], + "spouse": null +} \ No newline at end of file diff --git a/_sources/web/writeCode.rst b/_sources/web/writeCode.rst index 38ec7cc7..1dda0810 100644 --- a/_sources/web/writeCode.rst +++ b/_sources/web/writeCode.rst @@ -242,7 +242,7 @@ and email address. fh.close() person_list = json.loads(data) -The file ``person.json`` below contains JSON data for a person in a dictionary including their first name, +The file ``person2.json`` below contains JSON data for a person in a dictionary including their first name, last name, address, and phone numbers. .. reveal:: person2_data_rev @@ -288,7 +288,7 @@ last name, address, and phone numbers. .. activecode:: web_email_person_write_v2 :language: python3 :nocodelens: - :datafile: person.json + :datafile: person2.json Finish the code below so that it prints the first name, last name, the state the person lives in, and their mobile phone number from the JSON loaded from person2.json.