sanand0 / xmljson

xmlsjon converts XML into Python dictionary structures (trees, like in JSON) and vice-versa.
MIT License
121 stars 33 forks source link

Fix for 'single element array' issue. #42

Open CaFlow opened 4 years ago

CaFlow commented 4 years ago

Have added a method named Spark as it is like the Spark Convention.This is similar to the Parker method except that this method takes and extra list parameter 'single_element_array_tags'. Specified tags in this list are formatted in the json as single element arrays if there is only one child. After importing the required modules we can call this method as: formatted_json = dumps(spark.data(fromstring(''), preserve_root=True, single_element_array_tags=['<tag 1>','<tag 2>']), sort_keys=True, indent=4)