Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
json.dumps list output
#6
Ha, nice little printing exercise (one can print into file as well).

Using data from SO example:

>>> j = {'rows_parsed': [['a', 'b', 'c', 'd'], ['e', 'f', 'g', 'i']]}
>>> for k in j: 
...     print('{') 
...     print(f'{" " * 4}"{k}":  [') 
...     print(*[f'{" " * 8}{item}' for item in j[k]], sep=',\n') 
...     print(f'{" " * 4}]') 
...     print('}') 
...      
{
    "rows_parsed":  [
        ['a', 'b', 'c', 'd'],
        ['e', 'f', 'g', 'i']
    ]
}
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
json.dumps list output - by qurr - Mar-16-2020, 12:41 AM
RE: json.dumps list output - by Larz60+ - Mar-16-2020, 02:23 AM
RE: json.dumps list output - by qurr - Mar-16-2020, 07:32 AM
RE: json.dumps list output - by ndc85430 - Mar-16-2020, 07:52 AM
RE: json.dumps list output - by qurr - Mar-16-2020, 09:13 AM
RE: json.dumps list output - by ndc85430 - Mar-17-2020, 05:44 AM
RE: json.dumps list output - by perfringo - Mar-16-2020, 09:49 AM
RE: json.dumps list output - by Larz60+ - Mar-16-2020, 10:11 AM
RE: json.dumps list output - by qurr - Mar-16-2020, 05:07 PM
RE: json.dumps list output - by Larz60+ - Mar-16-2020, 08:58 PM
RE: json.dumps list output - by qurr - Mar-16-2020, 09:10 PM
RE: json.dumps list output - by Larz60+ - Mar-16-2020, 09:11 PM
RE: json.dumps list output - by micseydel - Apr-08-2020, 10:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Response.json list indices must be integers or slices, not str [SOLVED] AlphaInc 4 6,451 Mar-24-2023, 08:34 AM
Last Post: fullytotal
  sum() list from SQLAlchemy output Personne 5 4,489 May-17-2022, 12:25 AM
Last Post: Personne
  geojson to json --missing multiple row output yoshi 9 2,808 Mar-06-2022, 08:34 PM
Last Post: snippsat
Question convert unlabeled list of tuples to json (string) masterAndreas 4 7,484 Apr-27-2021, 10:35 AM
Last Post: masterAndreas
  How to append to list a function output? rama27 5 6,776 Aug-24-2020, 10:53 AM
Last Post: DeaD_EyE
  API JSON response missing list gives keyerror rolfmadsen 3 3,483 Mar-28-2020, 10:12 AM
Last Post: buran
  If item in list = true, Output = xx kroh 0 1,500 Feb-19-2020, 09:17 AM
Last Post: kroh
  Not Getting the Desired value using json.dumps saurabh210 0 1,519 Feb-03-2020, 06:48 PM
Last Post: saurabh210
  json.dumps output error in python3 prayuktibid 2 2,675 Jan-21-2020, 06:41 AM
Last Post: prayuktibid
  Output to a json file problem Netcode 3 3,749 Nov-22-2019, 01:44 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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