Anzeige JSON zurückgegeben von der Flasche in eine saubere Art und Weise

Ich bin erstellen einer API mit Flask und habe den folgenden code ein:

@app.route('/<major>/')
def major_res(major):
    course_list = list(client.db.course_col.find({"major": (major.encode("utf8", "ignore").upper())}))
    return json.dumps(course_list, sort_keys=True, indent=4, default=json_util.default)

Beim betrachten /csci/ im browser die Ausgabe sieht wie folgt aus:

[{ "course": "CSCI052", "description": "Fundamentals of Computer Science. A solid foundation in functional programming, procedural and data abstraction, recursion and problem-solving. Applications to key areas of computer science, including algorithms and complexity, computer architecture and organization, programming languages, finite automata and computability. This course serves the same role as HM 60 as a prerequisite for upper-division computer science courses at any of the Claremont Colleges. Prerequisite: 51.", "instructor": "Bull, Everett L.,, Jr.", "name": " Fundamentals of Computer Science", "number": 52, "school": "PO" }]

Wie kann ich wieder dieses Wörterbuch, so dass jeweils key und value werden auf Ihre eigene Linie?

InformationsquelleAutor Aloke Desai | 2013-06-04
Schreibe einen Kommentar