From e8a2fdb0176c9acad9c3560373728f2e325e158c Mon Sep 17 00:00:00 2001 From: giomba Date: Sun, 21 Oct 2018 11:30:59 +0200 Subject: [PATCH] Removed JSON<->XML issue Cannot be done automagically without some assumptions, so it is worth of doing the conversion by hand suited to our needs. --- TODO | 1 - tcparser.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 8ec2c84..e69de29 100644 --- a/TODO +++ b/TODO @@ -1 +0,0 @@ -- Properly automagically read interesting parts of XML into JSON diff --git a/tcparser.py b/tcparser.py index 9e06a34..15c9d86 100644 --- a/tcparser.py +++ b/tcparser.py @@ -24,6 +24,9 @@ def getLibrary(path): newbook['id'] = int(i.attrib['id']) # these `for` overwrite previous values, # but it is not an issue since actually these are one shot only elements + # actually there is no 1to1 conversion between XML and JSON, so this operation + # can not be made automagically without doing some preliminary assumptions + # (Possibly useful module: https://github.com/martinblech/xmltodict) for j in i.iter('title'): newbook['title'] = j.text for j in i.iter('publisher'):