Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieving items from JSON
#10
note that you can not have multiple identical keys in a dict. At each iteration of the first loop tenant_d is a dict with values for just one tenant. Then you print that dict and continue with next iteration if you look at the original json you will notice that tenants["items"] is actually a list of dicts. You need something like this to store the tenant_d if you want to keep all of them. Again that will replicate the original structure

after you finish the first loop tenant_d has the values for the last item in the list. that is what you iterate over and print in the second loop
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Retrieving items from JSON - by bazcurtis - Oct-24-2019, 05:31 PM
RE: Retrieving items from JSON - by buran - Oct-24-2019, 05:49 PM
RE: Retrieving items from JSON - by bazcurtis - Oct-24-2019, 09:03 PM
RE: Retrieving items from JSON - by bazcurtis - Oct-25-2019, 12:36 PM
RE: Retrieving items from JSON - by buran - Oct-25-2019, 12:43 PM
RE: Retrieving items from JSON - by bazcurtis - Oct-25-2019, 01:09 PM
RE: Retrieving items from JSON - by buran - Oct-25-2019, 01:12 PM
RE: Retrieving items from JSON - by bazcurtis - Oct-25-2019, 01:25 PM
RE: Retrieving items from JSON - by bazcurtis - Oct-25-2019, 03:02 PM
RE: Retrieving items from JSON - by buran - Oct-25-2019, 04:29 PM
RE: Retrieving items from JSON - by bazcurtis - Oct-25-2019, 05:40 PM
RE: Retrieving items from JSON - by buran - Oct-25-2019, 05:55 PM
RE: Retrieving items from JSON - by bazcurtis - Oct-27-2019, 05:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  KeyError while retrieving ESPN data john317ab 2 900 Nov-29-2023, 09:07 PM
Last Post: john317ab
  .get() not retrieving value? Sedos101 2 634 Aug-25-2023, 11:48 AM
Last Post: deanhystad
  [Solved] Retrieving a pdf from sqlite3 BigMan 4 2,454 Mar-12-2022, 01:56 PM
Last Post: deanhystad
  Retrieving a column from a data set using a function Bayle 6 2,447 Oct-06-2021, 08:52 PM
Last Post: Bayle
  Retrieving Cookies whois1230 2 2,246 Nov-21-2020, 12:01 PM
Last Post: snippsat
  Problem: Retrieving Form data PythonDev 3 3,175 Oct-16-2020, 02:09 AM
Last Post: PythonDev
  Retrieving dictionary keys within with another dictionay bazcurtis 8 2,957 Oct-29-2019, 10:06 PM
Last Post: bazcurtis
  Trouble retrieving dictionary from mysql.connector cursor swechsler 2 3,141 Sep-17-2019, 05:21 PM
Last Post: swechsler
  retrieving pvalue from statsmodels results Staph 4 3,120 Jul-18-2019, 03:27 PM
Last Post: Gribouillis
  PRAW and PyQt: Immense slowdown when retrieving Reddit posts and adding them to GUI codebro 2 3,286 Dec-30-2018, 01:19 AM
Last Post: codebro

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020