Created json formatter and validator. #82

Merged
koleckia merged 25 commits from features/json-parser-and-formatter into master 2023-02-28 12:51:13 +01:00
Showing only changes of commit 8083d7fa63 - Show all commits

View File

@@ -2,10 +2,20 @@ from lxml import etree
def prettify(source: str) -> str:
"""Method used to pretty format given XML
:param source: XML
:return: prettified XML
"""
xml = etree.XML(source)
return etree.tostring(xml, pretty_print=True).decode()
def minimize(source: str) -> str:
"""Method used to minimize XML by deleting not needed whitespaces.
:param source: XML
:return: minimized XML
"""
result = source
to_remove = [" ", " ", "\t", "\n"]