Print out .json line by line rather than all inside of one line

Viewed 15

Creating a script that will eventually allow users to enter a hardware/asset id and query an API to get back a bunch of information, currently in the process of simply printing out the entire JSON file and printing it, however it currently prints it all to one line and makes it near impossible to read, ideally it looks like the following:

name: x
owner: x
team: x

and so on and so forth however it prints

name: x owner: x team: x

Code is as follows:

import json
from json import dumps, loads

def json_format():
    json.dumps(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False)

def main():
    hardware_id = "x"
    asset_id = "x"
    host = get_information(asset_id='x')
    json_object = dumps(host)
    print(dumps(json_object, indent=4))

Tried following some pretty print guides however the above didn't fix the issue I'm facing, any ideas thank you! :D

0 Answers
Related